﻿using DevExpress.XtraGrid.Demos.util;
using DiaoPaiDaYin;
using Luna小店.DTO;
using Luna小店.model;
using Luna小店.service.WinForm_Service;
using Luna小店.UC.款式异常;
using Luna小店.UC.门店下单.DTO;
using Luna小店.UC.门店下单.form;
using Luna小店.Utils;
using Luna小店.原型;
using mendian;
using System;
using System.Collections.Generic;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace Luna小店.service
{
    /// <summary>
    /// 订单服务
    /// </summary>
    public class OrderService
    {
        public static void 更新同步订单状态(String ORDER_ID) {
            SQLmtm.ExecuteSql("UPDATE o_order_p \n" +
                "SET ORDER_STATUS_CD = 'ORDER_STATUS-OS_20' \n" +
                "WHERE\n" +
                "	ORDER_ID = '"+ ORDER_ID + "'");
        }
        /// <summary>
        /// 返回合同号
        /// </summary>
        /// <param name="CUSTOMER_ID"></param>
        /// <param name="CREATE_DATE_TIME"></param>
        /// <param name="ORDER_ID"></param>
        /// <returns></returns>
        public static String save合同(int CUSTOMER_ID, DateTime CREATE_DATE_TIME,String ORDER_ID) {
            DTO合同 dTO =new DTO合同(CUSTOMER_ID, CREATE_DATE_TIME);
            String sql = "INSERT INTO c_contract_custom_p (\n" +
                "	CONTRACT_NO,\n" +
                "	CUSTOMER_ID,\n" +
                "	ORDER_TYPE_CD,\n" +
                "	CONTRACT_ISSUE_DATE,\n" +
                "	CONTRACT_CURRENCY_CD,\n" +
                "	CONTRACT_EXCHANGE_RATE,\n" +
                "	CONTRACT_TRANSPORT_MODE,\n" +
                "	CONTRACT_DELIVERY_DATE,\n" +
                "	CONTRACT_AUDIT_STATUS,\n" +
                "	CONTRACT_STATUS,\n" +
                "	CARTON_INFO_STATUS,\n" +
                "	UNIT_COST_STATUS,\n" +
                "	FINANCE_STATUS,\n" +
                "	CONTRACT_SYNC_STATUS,\n" +
                "	CONTRACT_SYNC_STATUS_MTM,\n" +
                "	DEL_FLG,\n" +
                "	VERSION,\n" +
                "	CREATE_USER_ID,\n" +
                "	CREATE_DATE_TIME,\n" +
                "	UPDATE_USER_ID,\n" +
                "	UPDATE_DATE_TIME \n" +
                ")\n" +
                "VALUES\n" +
                "	( "+
                "		'" + dTO.CONTRACT_NO + "',\n" +
                "		'" + dTO.CUSTOMER_ID + "',\n" +
                "		'" + dTO.ORDER_TYPE_CD + "',\n" +
                "		'" + dTO.CONTRACT_ISSUE_DATE + "',\n" +
                "		'" + dTO.CONTRACT_CURRENCY_CD + "',\n" +
                "		'" + dTO.CONTRACT_EXCHANGE_RATE + "',\n" +
                "		'" + dTO.CONTRACT_TRANSPORT_MODE + "',\n" +
                "		'" + dTO.CONTRACT_DELIVERY_DATE + "',\n" +
                "		'" + dTO.CONTRACT_AUDIT_STATUS + "',\n" +
                "		'" + dTO.CONTRACT_STATUS + "',\n" +
                "		'" + dTO.CARTON_INFO_STATUS + "',\n" +
                "		'" + dTO.UNIT_COST_STATUS + "',\n" +
                "		'" + dTO.FINANCE_STATUS + "',\n" +
                "		'" + dTO.CONTRACT_SYNC_STATUS + "',\n" +
                "		'" + dTO.CONTRACT_SYNC_STATUS_MTM + "',\n" +
                "		'" + dTO.DEL_FLG + "',\n" +
                "		'" + dTO.VERSION + "',\n" +
                "		'" + dTO.CREATE_USER_ID + "',\n" +
                "		'" + dTO.CREATE_DATE_TIME + "',\n" +
                "		'" + dTO.UPDATE_USER_ID + "',\n" +
                "		'" + dTO.UPDATE_DATE_TIME + "'\n" +
                " )";
            SQLerp.ExecuteSql(sql);
            String CONTRACT_ID = SQLerp.GetDataRow("select MAX(CONTRACT_ID) as CONTRACT_ID from c_contract_custom_p")["CONTRACT_ID"].ToString();
            //  关联表
            SQLerp.ExecuteSql(
                "INSERT INTO c_contract_custom_order_r ( CONTRACT_ID, ORDER_ID, CARTON_INFO_STATUS )\n" +
                "VALUES\n" +
                "	( '"+ CONTRACT_ID + "', '"+ ORDER_ID + "', 3 )"
                );
            return dTO.CONTRACT_NO;
        }
        public static string save同步订单(DTO订单同步 dTO) {
            String sql = "INSERT INTO o_order_p (\n" +
                "	ORDER_NO,\n" +
                "	ORDER_TYPE_CD,\n" +
                "	SHOP_ID,\n" +
                "	SHOP_NAME,\n" +
                "	CUSTOM_ORDER_NO,\n" +
                "	CUSTOM_NAME,\n" +
                "	CUSTOM_MAKE_SHIRT,\n" +
                "	TRANSIT_GROUP,\n" +
                "	COUNTRY,\n" +
                "	SLEEVE_FLAG,\n" +
                "	CUSTOMER_ID,\n" +
                "	CUSTOMER_NAME,\n" +
                "	FACTORY_ID,\n" +
                "	STYLE_ID,\n" +
                //"	REF_ORDER_ID,\n" +
                "	SPECIAL_ORDER,\n" +
                "	TRYON_ORDER,\n" +
                //"	FIT_STYLE_SIZE,\n" +
                //"	TAILOR_ID,\n" +
                "	SHIPPING_DESTINATION,\n" +
                "	ORDER_DATE,\n" +
                "	PAYMENT_DATE,\n" +
                //"	PAYMENT_CONFIRM_DATE,\n" +
                //"	ORDER_ACCEPT_DATE,\n" +
                //"	ORDER_PRO_START_DATE,\n" +
                //"	ORDER_PRO_END_DATE,\n" +
                //"	ORDER_PACK_DATE,\n" +
                //"	ORDER_SHIPMENTS_DATE,\n" +
                "	TARGET_DATE,\n" +
                //"	REAL_DATE,\n" +
                "	ORDER_STATUS_CD,\n" +
                "	ORDER_PRODUCE_STATUS_CD,\n" +
                "	ORDER_QC34,\n" +
                "	ORDER_QC35,\n" +
                "	ORDER_QC36,\n" +
                "	ORDER_QC37,\n" +
                "	ORDER_NUMBER,\n" +
                //"	ORDER_MATERIAL_COST,\n" +
                //"	ORDER_DESIGN_COST,\n" +
                //"	ORDER_PROCESS_COST,\n" +
                "	ORDER_PACK_COST,\n" +
                "	ORDER_EXPRESS_COST,\n" +
                //"	ORDER_SELL_ACCOUNT,\n" +
                "	ORDER_OTHER_COST,\n" +
                "	URGENT_CD,\n" +
                "	MATERIAL_SOURCE,\n" +
                "	REMARKS,\n" +
                "	DELETE_FLAG,\n" +
                "	VERSION,\n" +
                "	CREATE_DATE,\n" +
                //"	UPDATE_DATE,\n" +
                "	CREATE_USER,\n" +
                //"	UPDATE_USER,\n" +
                "	SEL_KBN,\n" +
                "	PRINT_FLAG \n" +
                ")\n" +
                "VALUES\n" +
                "	( \n" +
                "		'" + dTO.ORDER_NO + "',\n" +
                "		'" + dTO.ORDER_TYPE_CD + "',\n" +
                "		'" + dTO.SHOP_ID + "',\n" +
                "		'" + dTO.SHOP_NAME + "',\n" +
                "		'" + dTO.CUSTOM_ORDER_NO + "',\n" +
                "		'" + dTO.CUSTOM_NAME + "',\n" +
                "		'" + dTO.CUSTOM_MAKE_SHIRT + "',\n" +
                "		'" + dTO.TRANSIT_GROUP + "',\n" +
                "		'" + dTO.COUNTRY + "',\n" +
                "		'" + (String.IsNullOrEmpty(dTO.SLEEVE_FLAG)? "0":dTO.SLEEVE_FLAG) + "',\n" +
                "		'" + dTO.CUSTOMER_ID + "',\n" +
                "		'" + dTO.CUSTOMER_NAME + "',\n" +
                "		'" + dTO.FACTORY_ID + "',\n" +
                "		'" + dTO.STYLE_ID + "',\n" +
                //"		'" + dTO.REF_ORDER_ID + "',\n" +
                "		'" + dTO.SPECIAL_ORDER + "',\n" +
                "		'" + dTO.TRYON_ORDER + "',\n" +
                //"		'" + dTO.FIT_STYLE_SIZE + "',\n" +
                //"		'" + dTO.TAILOR_ID + "',\n" +
                "		'" + dTO.SHIPPING_DESTINATION + "',\n" +
                "		'" + dTO.ORDER_DATE + "',\n" +
                "		'" + dTO.PAYMENT_DATE + "',\n" +
                //"		'" + dTO.PAYMENT_CONFIRM_DATE + "',\n" +
                //"		'" + dTO.ORDER_ACCEPT_DATE + "',\n" +
                //"		'" + dTO.ORDER_PRO_START_DATE + "',\n" +
                //"		'" + dTO.ORDER_PRO_END_DATE + "',\n" +
                //"		'" + dTO.ORDER_PACK_DATE + "',\n" +
                //"		'" + dTO.ORDER_SHIPMENTS_DATE + "',\n" +
                "		'" + (String.IsNullOrEmpty(dTO.TARGET_DATE)? DateTime.Now.AddDays(7).ToString(): dTO.TARGET_DATE) + "',\n" +
                //"		'" + dTO.REAL_DATE + "',\n" +
                "		'" + dTO.ORDER_STATUS_CD + "',\n" +
                "		'" + dTO.ORDER_PRODUCE_STATUS_CD + "',\n" +
                "		'" + dTO.ORDER_QC34 + "',\n" +
                "		'" + dTO.ORDER_QC35 + "',\n" +
                "		'" + dTO.ORDER_QC36 + "',\n" +
                "		'" + dTO.ORDER_QC37 + "',\n" +
                "		'" + dTO.ORDER_NUMBER + "',\n" +
                //"		'" + dTO.ORDER_MATERIAL_COST + "',\n" +
                //"		'" + dTO.ORDER_DESIGN_COST + "',\n" +
                //"		'" + dTO.ORDER_PROCESS_COST + "',\n" +
                "		'" + dTO.ORDER_PACK_COST + "',\n" +
                "		'" + dTO.ORDER_EXPRESS_COST + "',\n" +
                //"		'" + dTO.ORDER_SELL_ACCOUNT + "',\n" +
                "		'" + dTO.ORDER_OTHER_COST + "',\n" +
                "		'" + dTO.URGENT_CD + "',\n" +
                "		'" + dTO.MATERIAL_SOURCE + "',\n" +
                "		'" + dTO.REMARKS + "',\n" +
                "		'" + dTO.DELETE_FLAG + "',\n" +
                "		'" + dTO.VERSION + "',\n" +
                "		'" + dTO.CREATE_DATE + "',\n" +
                //"		'" + dTO.UPDATE_DATE + "',\n" +
                "		'" + dTO.CREATE_USER + "',\n" +
                //"		'" + dTO.UPDATE_USER + "',\n" +
                "		'" + dTO.SEL_KBN + "',\n" +
                "		'" + dTO.PRINT_FLAG + "'\n" +
                ")";
            SQLerp.ExecuteSql(sql);
            String ORDER_ID = SQLerp.GetDataRow("select MAX(ORDER_ID) as ORDER_ID from o_order_p")["ORDER_ID"].ToString();

            //  订单关联表
            sql = "INSERT INTO o_order_style_r ( ORDER_ID, SYS_STYLE_ID )\n" +
            "VALUES\n" +
            "	( '"+ ORDER_ID + "', '"+ dTO.STYLE_ID + "' );";
            SQLerp.ExecuteSql(sql);
            return ORDER_ID;
        }

        public static String save同步款式(DTO款式同步 dTO) {
            String sql = "INSERT INTO s_style_p (\n" +
                "	STYLE_NO,\n" +
                "	STYLE_CD,\n" +
                "	STYLE_KBN,\n" +
                "	STYLE_SOURCE,\n" +
                "	STYLE_CATEGORY_CD,\n" +
                "	REF_STYLE_ID,\n" +
                "	STYLE_NAME_CN,\n" +
                "	STYLE_NAME_EN,\n" +
                "	STYLE_FIT_CD,\n" +
                "	SYTLE_YEAR,\n" +
                "	SYTLE_SEASON,\n" +
                "	SYTLE_FABRIC_ID,\n" +
                "	SYTLE_FABRIC_NO,\n" +
                "	STYLE_COMPOSITION,\n" +
                "	STYLE_DESCRIBE,\n" +
                "	STYLE_COLOR_CD,\n" +
                "	STYLE_COLOR_NAME,\n" +
                "	STYLE_SIZE_GROUP_CD,\n" +
                "	STYLE_SIZE_CD,\n" +
                "	STYLE_MAKE_TYPE,\n" +
                "	STYLE_FIT_BODY_TYPE,\n" +
                "	STYLE_SEX_CD,\n" +
                "	STYLE_STANDARD,\n" +
                "	STYLE_BAR_CODE,\n" +
                //"	STYLE_DESIGNER_DATE,\n" +
                //"	STYLE_DESIGNER,\n" +
                "	STYLE_MATERIAL_NUMBER,\n" +
                "	STYLE_DESIGN_PRICE,\n" +
                "	STYLE_FACTORY_TOTAL_PRICE,\n" +
                "	STYLE_SHOP_TOTAL_PRICE,\n" +
                "	REMARKS,\n" +
                "	ENABLE_FLAG,\n" +
                "	DELETE_FLAG,\n" +
                "	VERSION,\n" +
                "	CREATE_DATE,\n" +
                "	UPDATE_DATE,\n" +
                //"	UPDATE_USER,\n" +
                "	CREATE_USER " +
                ")\n" +
                "VALUES\n" +
                "	(\n" +
                "		'" + dTO.STYLE_NO + "',\n" +
                "		'" + dTO.STYLE_CD + "',\n" +
                "		'" + dTO.STYLE_KBN + "',\n" +
                "		'" + dTO.STYLE_SOURCE + "',\n" +
                "		'" + dTO.STYLE_CATEGORY_CD + "',\n" +
                "		'" + dTO.REF_STYLE_ID + "',\n" +
                "		'" + dTO.STYLE_NAME_CN + "',\n" +
                "		'" + dTO.STYLE_NAME_EN + "',\n" +
                "		'" + dTO.STYLE_FIT_CD + "',\n" +
                "		'" + dTO.SYTLE_YEAR + "',\n" +
                "		'" + dTO.SYTLE_SEASON + "',\n" +
                "		'" + dTO.SYTLE_FABRIC_ID + "',\n" +
                "		'" + dTO.SYTLE_FABRIC_NO + "',\n" +
                "		'" + dTO.STYLE_COMPOSITION + "',\n" +
                "		'" + dTO.STYLE_DESCRIBE + "',\n" +
                "		'" + dTO.STYLE_COLOR_CD + "',\n" +
                "		'" + dTO.STYLE_COLOR_NAME + "',\n" +
                "		'" + dTO.STYLE_SIZE_GROUP_CD + "',\n" +
                "		'" + dTO.STYLE_SIZE_CD + "',\n" +
                "		'" + dTO.STYLE_MAKE_TYPE + "',\n" +
                "		'" + dTO.STYLE_FIT_BODY_TYPE + "',\n" +
                "		'" + dTO.STYLE_SEX_CD + "',\n" +
                "		'" + dTO.STYLE_STANDARD + "',\n" +
                "		'" + dTO.STYLE_BAR_CODE + "',\n" +
                //"		'" + dTO.STYLE_DESIGNER_DATE + "',\n" +
                //"		'" + dTO.STYLE_DESIGNER + "',\n" +
                "		'" + dTO.STYLE_MATERIAL_NUMBER + "',\n" +
                "		'" + dTO.STYLE_DESIGN_PRICE + "',\n" +
                "		'" + dTO.STYLE_FACTORY_TOTAL_PRICE + "',\n" +
                "		'" + dTO.STYLE_SHOP_TOTAL_PRICE + "',\n" +
                "		'" + dTO.REMARKS + "',\n" +
                "		'" + dTO.ENABLE_FLAG + "',\n" +
                "		'" + dTO.DELETE_FLAG + "',\n" +
                "		'" + dTO.VERSION + "',\n" +
                "		'" + dTO.CREATE_DATE + "',\n" +
                "		'" + dTO.UPDATE_DATE + "',\n" +
                //"		'" + dTO.UPDATE_USER + "',\n" +
                "		'" + dTO.CREATE_USER + "'\n" +                
                "	)";
            SQLerp.ExecuteSql(sql);
            return SQLerp.GetDataRow("select MAX(SYS_STYLE_ID) as SYS_STYLE_ID from s_style_p")["SYS_STYLE_ID"].ToString();
        }

        public static DTO款式同步 get同步款式(String SYS_STYLE_ID) {
            String sql = "SELECT\n" +
                "	s_style_p.SYS_STYLE_ID,\n" +
                "	s_style_p.STYLE_NO,\n" +
                "	s_style_p.STYLE_CD,\n" +
                "	s_style_p.STYLE_KBN,\n" +
                "	s_style_p.STYLE_SOURCE,\n" +
                "	s_style_p.STYLE_CATEGORY_CD,\n" +
                "	s_style_p.REF_STYLE_ID,\n" +
                "	s_style_p.STYLE_NAME_CN,\n" +
                "	s_style_p.STYLE_NAME_EN,\n" +
                "	s_style_p.STYLE_FIT_CD,\n" +
                "	s_style_p.SYTLE_YEAR,\n" +
                "	s_style_p.SYTLE_SEASON,\n" +
                "	s_style_p.SYTLE_FABRIC_ID,\n" +
                "	s_style_p.SYTLE_FABRIC_NO,\n" +
                "	s_style_p.STYLE_COMPOSITION,\n" +
                "	s_style_p.STYLE_DESCRIBE,\n" +
                "	s_style_p.STYLE_COLOR_CD,\n" +
                "	s_style_p.STYLE_COLOR_NAME,\n" +
                "	s_style_p.STYLE_SIZE_GROUP_CD,\n" +
                "	s_style_p.STYLE_SIZE_CD,\n" +
                "	s_style_p.STYLE_MAKE_TYPE,\n" +
                "	s_style_p.STYLE_FIT_BODY_TYPE,\n" +
                "	s_style_p.STYLE_SEX_CD,\n" +
                "	s_style_p.STYLE_STANDARD,\n" +
                "	s_style_p.STYLE_BAR_CODE,\n" +
                "	s_style_p.STYLE_DESIGNER_DATE,\n" +
                "	s_style_p.STYLE_DESIGNER,\n" +
                "	s_style_p.STYLE_MATERIAL_NUMBER,\n" +
                "	s_style_p.STYLE_DESIGN_PRICE,\n" +
                "	s_style_p.STYLE_FACTORY_TOTAL_PRICE,\n" +
                "	s_style_p.STYLE_SHOP_TOTAL_PRICE,\n" +
                "	s_style_p.REMARKS,\n" +
                "	s_style_p.ENABLE_FLAG,\n" +
                "	s_style_p.DELETE_FLAG,\n" +
                "	s_style_p.VERSION,\n" +
                "	s_style_p.CREATE_DATE,\n" +
                "	s_style_p.UPDATE_DATE,\n" +
                "	s_style_p.CREATE_USER,\n" +
                "	s_style_p.UPDATE_USER \n" +
                "FROM\n" +
                "	s_style_p \n" +
                "WHERE\n" +
                "	SYS_STYLE_ID = '"+ SYS_STYLE_ID + "'";
            return new DTO款式同步(SQLmtm.GetDataRow(sql));
        }

        public static DTO订单同步 get同步订单(String order_id) {
            String sql = "SELECT\n" +
                "	ORDER_ID,\n" +
                "	ORDER_NO,\n" +
                "	ORDER_TYPE_CD,\n" +
                "	SHOP_ID,\n" +
                "	SHOP_NAME,\n" +
                "	CUSTOM_ORDER_NO,\n" +
                "	CUSTOM_NAME,\n" +
                "	CUSTOM_MAKE_SHIRT,\n" +
                "	TRANSIT_GROUP,\n" +
                "	COUNTRY,\n" +
                "	SLEEVE_FLAG,\n" +
                "	CUSTOMER_ID,\n" +
                "	CUSTOMER_NAME,\n" +
                "	FACTORY_ID,\n" +
                "	STYLE_ID,\n" +
                "	REF_ORDER_ID,\n" +
                "	SPECIAL_ORDER,\n" +
                "	TRYON_ORDER,\n" +
                "	FIT_STYLE_SIZE,\n" +
                "	TAILOR_ID,\n" +
                "	SHIPPING_DESTINATION,\n" +
                "	ORDER_DATE,\n" +
                "	PAYMENT_DATE,\n" +
                "	PAYMENT_CONFIRM_DATE,\n" +
                "	ORDER_ACCEPT_DATE,\n" +
                "	ORDER_PRO_START_DATE,\n" +
                "	ORDER_PRO_END_DATE,\n" +
                "	ORDER_PACK_DATE,\n" +
                "	ORDER_SHIPMENTS_DATE,\n" +
                "	TARGET_DATE,\n" +
                "	REAL_DATE,\n" +
                "	ORDER_STATUS_CD,\n" +
                "	ORDER_PRODUCE_STATUS_CD,\n" +
                "	ORDER_QC34,\n" +
                "	ORDER_QC35,\n" +
                "	ORDER_QC36,\n" +
                "	ORDER_QC37,\n" +
                "	ORDER_NUMBER,\n" +
                "	ORDER_MATERIAL_COST,\n" +
                "	ORDER_DESIGN_COST,\n" +
                "	ORDER_PROCESS_COST,\n" +
                "	ORDER_PACK_COST,\n" +
                "	ORDER_EXPRESS_COST,\n" +
                "	ORDER_SELL_ACCOUNT,\n" +
                "	ORDER_OTHER_COST,\n" +
                "	URGENT_CD,\n" +
                "	MATERIAL_SOURCE,\n" +
                "	REMARKS,\n" +
                "	DELETE_FLAG,\n" +
                "	VERSION,\n" +
                "	CREATE_DATE,\n" +
                "	UPDATE_DATE,\n" +
                "	CREATE_USER,\n" +
                "	UPDATE_USER,\n" +
                "	SEL_KBN,\n" +
                "	PRINT_FLAG \n" +
                "FROM\n" +
                "	o_order_p \n" +
                "WHERE\n" +
                "	order_id = '"+ order_id + "'";
            return new DTO订单同步(SQLmtm.GetDataRow(sql));
        }

        public static List<DTODesignPoints> get同步设计点(String styleid)
        {
            List<DTODesignPoints> dtos = new List<DTODesignPoints>();
            String sql = "SELECT\n" +
                "	s_style_option_r.SYTLE_OPTION_ID,\n" +
                "	s_style_option_r.SYS_STYLE_ID,\n" +
                "	s_style_option_r.ITEM_CD,\n" +
                "	s_style_option_r.ITEM_VALUE,\n" +
                "	s_style_option_r.OPTION_VALUE,\n" +
                "	s_style_option_r.ITEM_TYPE_NAME_CN,\n" +
                "	s_style_option_r.ITEM_NAME_CN,\n" +
                "	w_upload_file_p.UPLOAD_FILE \n" +
                "FROM\n" +
                "	(\n" +
                "	SELECT\n" +
                "		sr.SYTLE_OPTION_ID,\n" +
                "		sr.SYS_STYLE_ID,\n" +
                "		sr.ITEM_CD,\n" +
                "		sr.ITEM_VALUE,\n" +
                "		sr.OPTION_VALUE,\n" +
                "		ap1.ITEM_NAME_CN AS ITEM_TYPE_NAME_CN,\n" +
                "		ap.ITEM_NAME_CN,\n" +
                "		ap.FILE_ID \n" +
                "	FROM\n" +
                "		s_style_option_r AS sr\n" +
                "		LEFT JOIN a_designoption_p AS ap1 ON sr.ITEM_VALUE = ap1.ITEM_VALUE\n" +
                "		LEFT JOIN a_designoption_p AS ap ON sr.OPTION_VALUE = ap.ITEM_VALUE \n" +
                "		AND sr.ITEM_VALUE = ap.ITEM_CD \n" +
                "	WHERE\n" +
                "		sr.SYS_STYLE_ID = '" + styleid + "' \n" +
                "		-- AND ap.ITEM_NAME_CN IS NOT NULL \n" +
                "	) AS s_style_option_r\n" +
                "	LEFT JOIN w_upload_file_p ON w_upload_file_p.FILE_ID = s_style_option_r.FILE_ID";
            foreach (DataRow dr in SQLmtm.GetDataTable(sql).Rows)
            {
                dtos.Add(new DTODesignPoints(dr));
            }
            return dtos;
        }

        public static Boolean save同步设计点(List<DTODesignPoints> dtos,String styleid)
        {
            try
            {
                foreach (DTODesignPoints dto in dtos)
                {
                    String sql = "INSERT INTO `fragsmart-erp`.`s_style_option_r` (\n" +
                                    "	`SYS_STYLE_ID`,\n" +
                                    "	`ITEM_CD`,\n" +
                                    "	`ITEM_VALUE`,\n" +
                                    "	`OPTION_VALUE`,\n" +
                                    "	`ENABLE_FLAG`,\n" +
                                    "	`DELETE_FLAG`,\n" +
                                    "	`VERSION`\n" +
                                    ")\n" +
                                    "VALUES\n" +
                                    "	(\n" +
                                    "		" + styleid + ",\n" +
                                    "		'" + dto.itemCd + "',\n" +
                                    "		'" + dto.itemValue + "',\n" +
                                    "		'" + dto.optionValue + "',\n" +
                                    "		1,\n" +
                                    "		0,\n" +
                                    "		1\n" +
                                    "	);";
                    SQLerp.ExecuteSql(sql);
                }
                return true;
            }
            catch
            {
                MessageBox.Show("同步设计点失败");
                return false;
            }
        }

        public static List<Order_Status> getOrderStatus() {
            String sql = "SELECT\n" +
                "	CONCAT( ITEM_CD, '-', ITEM_VALUE ) AS ITEM_VALUE,\n" +
                "	ITEM_NAME_CN \n" +
                "FROM\n" +
                "	a_dict_p \n" +
                "WHERE\n" +
                "	item_cd LIKE 'ORDER_STATUS'";
            DataTable dataTable = SQLmtm.GetDataTable(sql);

            List<Order_Status> order_Statuses = new List<Order_Status>();
            order_Statuses.Add(new Order_Status("全部"));

            foreach (DataRow dataRow in dataTable.Rows) {
                order_Statuses.Add(new Order_Status(dataRow));
            }
            return order_Statuses;
        }
        /// <summary>
        /// 查询订单
        /// </summary>
        /// <param name="orderno"></param>
        /// <returns></returns>
        public static DataTable GetOrder(String orderno, int order_type)
        {
            String sql = "SELECT * FROM v_order_with_type WHERE order_type ='" + order_type + "'" +
                " and ORDER_NO = '" + orderno + "'";
            return SQLmtm.GetDataTable(sql);
        }

        /// <summary>
        /// 查询未打印订单
        /// </summary>
        /// <param name="orderno"></param>
        /// <returns></returns>
        public static DataTable GetNotPrintedData(String orderno, DateTime startTime, DateTime endTime, int order_type)
        {
            String sql = "SELECT " +
                "	*  " +
                "FROM " +
                "	v_order_with_type " +
                "WHERE " +
                "	ORDER_NO NOT IN ( SELECT ORDER_NO FROM a_product_log_p ) " +
                "	AND ORDER_NO LIKE '%" + orderno + "%' " +
                " and ORDER_DATE between '" + startTime.ToString() + "' and '" + endTime.ToString() + "'" +
                " and order_type ='" + order_type + "'" +
                "	order by ORDER_DATE";
            return SQLmtm.GetDataTable(sql);
        }

        /// <summary>
        /// 订单类型
        /// </summary>
        /// <returns></returns>
        public static DataTable getOrderTypeCode()
        {
            String sql = "select * from t_order_type_code;";
            return SQLmtm.GetDataTable(sql);
        }

        public static List<DTODesignPoints> get设计点BySYS_STYLE_ID(String SYS_STYLE_ID) {
            String sql = "SELECT\n" +
                "	s_style_option_r.SYTLE_OPTION_ID,\n" +
                "	s_style_option_r.SYS_STYLE_ID,\n" +
                "	s_style_option_r.ITEM_CD,\n" +
                "	s_style_option_r.ITEM_VALUE,\n" +
                "	s_style_option_r.OPTION_VALUE,\n" +
                "	s_style_option_r.ITEM_TYPE_NAME_CN,\n" +
                "	s_style_option_r.ITEM_NAME_CN,\n" +
                "	w_upload_file_p.UPLOAD_FILE \n" +
                "FROM\n" +
                "	(\n" +
                "	SELECT\n" +
                "		sr.SYTLE_OPTION_ID,\n" +
                "		sr.SYS_STYLE_ID,\n" +
                "		sr.ITEM_CD,\n" +
                "		sr.ITEM_VALUE,\n" +
                "		sr.OPTION_VALUE,\n" +
                "		ap1.ITEM_NAME_CN AS ITEM_TYPE_NAME_CN,\n" +
                "		ap.ITEM_NAME_CN,\n" +
                "		ap.FILE_ID \n" +
                "	FROM\n" +
                "		s_style_option_r AS sr\n" +
                "		LEFT JOIN a_designoption_p AS ap1 ON sr.ITEM_VALUE = ap1.ITEM_VALUE\n" +
                "		LEFT JOIN a_designoption_p AS ap ON sr.OPTION_VALUE = ap.ITEM_VALUE \n" +
                "		AND sr.ITEM_VALUE = ap.ITEM_CD \n" +
                "	WHERE\n" +
                "		sr.SYS_STYLE_ID = '" + SYS_STYLE_ID + "' \n" +
                "		-- AND ap.ITEM_NAME_CN IS NOT NULL \n" +
                "	) AS s_style_option_r\n" +
                "	LEFT JOIN w_upload_file_p ON w_upload_file_p.FILE_ID = s_style_option_r.FILE_ID";
            List<DTODesignPoints> 设计点s = new List<DTODesignPoints>();

            DataTable dataTable = SQLmtm.GetDataTable(sql);
            foreach (DataRow dataRow in dataTable.Rows) {
                设计点s.Add(new DTODesignPoints(dataRow));
            }
            return 设计点s;
        }


        /// <summary>
        /// 动态保存订单
        /// </summary>
        /// <param name="orderDto"></param>
        public static void DynamicSaveOrder(OrderDto orderDto)
        {
            DataRow drstyle = SQLmtm.GetDataRow("SELECT MAX(SYS_STYLE_ID) SYS_STYLE_ID FROM `s_style_p`");
            orderDto.styleId = (Convert.ToInt32(drstyle["SYS_STYLE_ID"]) + 1).ToString();
            //orderDto.style_id = FunctionHelper.generateBillNo("s_style_p", "SYS_STYLE_ID", "", "0000");
            SQLmtm.DoInsert(
                "s_style_fit_r"
                , new string[] { "STYLE_ID", "PHASE_CD", "ITEM_CD", "ITEM_VALUE", "FIT_VALUE", "FM_VALUE", "DELETE_FLAG", "VERSION", "CREATE_USER", "IN_VALUE", "OUT_VALUE" }
                , new string[] { orderDto.styleId, "AUDIT_PHASE_CD-PHASE_CD_10", orderDto.dtoSize.itemCd, orderDto.dtoSize.itemValue, orderDto.dtoSize.fitValue, orderDto.dtoSize.fmValue, "0", "1", "46", orderDto.dtoSize.inValue, orderDto.dtoSize.outValue }
                );
            SQLmtm.DoInsert(
                "a_customer_fit_value_r"
                , new string[] { "CUSTOMER_ID", "CUSTOMER_NAME", "ITEM_CD", "ITEM_VALUE", "FIT_VALUE", "FM_VALUE", "IN_VALUE", "OUT_VALUE", "STATUS", "DELETE_FLAG", "CUSTOMER_COUNT_ID" }
                , new string[] { orderDto.customerId, orderDto.customerName, orderDto.dtoSize.itemCd, orderDto.dtoSize.itemValue, orderDto.dtoSize.fitValue, orderDto.dtoSize.fmValue, orderDto.dtoSize.inValue, orderDto.dtoSize.outValue, "0", "0", orderDto.customerCountId }
                );
            SQLmtm.DoInsert(
                "s_style_p"
                , new string[] { "SYS_STYLE_ID", "SHOP_ID", "STYLE_CD", "STYLE_KBN", "STYLE_CATEGORY_CD", "SYTLE_FABRIC_ID", "STYLE_SIZE_GROUP_CD", "STYLE_SIZE_CD", "STYLE_MAKE_TYPE", "ENABLE_FLAG", "DELETE_FLAG", "VERSION", "STYLE_NAME_CN", "REMARKS", "CUSTOMER_COUNT_ID", "STYLE_FIT_CD", "REF_STYLE_ID", "STYLE_DRESS_CATEGORY", "STYLE_DESIGN_TYPE", "STYLE_PUBLISH_CATEGORY_CD", "SYTLE_YEAR", "SYTLE_SEASON" }
                , new string[] { orderDto.styleId, "18", "", "STYLE_SOURCE-STYLE_SOURCE_50", orderDto.styleCategoryCd, orderDto.styleFabricId, orderDto.styleSizeGroupCd, orderDto.styleSizeCd, orderDto.styleMakeType, "1", "0", "1", orderDto.styleNameCn, orderDto.remarks, orderDto.customerCountId, orderDto.styleFitCd, orderDto.refStyleId, orderDto.styleDressCategory, orderDto.styleDesignType, orderDto.stylePublishCategoryCd, orderDto.styleYear, orderDto.styleSeason }
                );
            //保存尺寸,同步尺寸日志
            String json1 = RestCall.httpGetMethod(URL.接口url + "/style/saveMeasureSession?sessionId=" + orderDto.sessionId + "&styleId=" + orderDto.styleId);
            foreach (DTODesignPoints dto in orderDto.dtoDesignPoints)
            {
                SQLmtm.DoInsert("s_style_option_r", new string[] { "SYS_STYLE_ID", "ITEM_CD", "ITEM_VALUE", "OPTION_VALUE", "ENABLE_FLAG", "DELETE_FLAG" }, new string[] { orderDto.styleId, dto.itemCd, dto.itemValue, dto.optionValue, "1", "0" });
            }
            if (orderDto.orderSalesType == Enum订单类型.春衫订单)
            {
                RestCall.httpGetMethod(URL.接口url + "/barcode/generateOrderInfo?customerId=" + orderDto.customerId + "&styleId=" + orderDto.styleId + "&orderNumber=" + orderDto.orderNumber);
                //RestCall.httpGetMethod("https://shirtmtm.com/fragsmart-mtm/customer/update/payment?styleId=" + orderDto.style_id + "&customerId=" + orderDto.CUSTOMER_ID + "&addressId=" + orderDto.ADDRESS_ID + "&number=" + orderDto.ORDER_NUMBER);
                //RestCall.httpGetMethod("http://localhost:8080/customer/update/payment?styleId=" + orderDto.style_id + "&customerId=" + orderDto.CUSTOMER_ID + "&addressId=" + orderDto.ADDRESS_ID + "&number=" + orderDto.ORDER_NUMBER);
                int order_id = Convert.ToInt32(SQLmtm.GetDataRow("SELECT MAX(ORDER_ID) AS ORDER_ID FROM `o_order_p`")["ORDER_ID"].ToString());
                String orderCommit = RestCall.PostHttp(URL.接口url + "/barcode/orderCommit",order_id.ToString());
                foreach (备注图片 rp in orderDto.remarksPicture)
                {
                    String str = FileService.UploadRequest(URL.接口url + "/image/uploadMemoImage?orderId=" + order_id.ToString(), rp.PATH, rp.NAME, "multipartFile");
                }
                //order_id++;
                SQLmtm.DoInsert("o_order_brand_r", new string[] { "OGNIZATION_ID", "SHOP_ID", "BRAND_ID", "ORDER_ID" }, new string[] { "95", "18", "", order_id.ToString() });
            }
            else if (orderDto.orderSalesType == Enum订单类型.Luna店铺)
            {

            }
            else if (orderDto.orderSalesType == Enum订单类型.套号订单)
            {
                RestCall.httpGetMethod(URL.接口url + "/barcode/generateOrderInfo?customerId=" + orderDto.customerId + "&styleId=" + orderDto.styleId + "&orderNumber=" + orderDto.orderNumber);
                //RestCall.httpGetMethod("https://shirtmtm.com/fragsmart-mtm/customer/update/payment?styleId=" + orderDto.style_id + "&customerId=" + orderDto.CUSTOMER_ID + "&addressId=" + orderDto.ADDRESS_ID + "&number=" + orderDto.ORDER_NUMBER);
                //RestCall.httpGetMethod("http://localhost:8080/customer/update/payment?styleId=" + orderDto.style_id + "&customerId=" + orderDto.CUSTOMER_ID + "&addressId=" + orderDto.ADDRESS_ID + "&number=" + orderDto.ORDER_NUMBER);
                int order_id = Convert.ToInt32(SQLmtm.GetDataRow("SELECT MAX(ORDER_ID) AS ORDER_ID FROM `o_order_p`")["ORDER_ID"].ToString());
                String orderCommit = RestCall.PostHttp(URL.接口url + "/barcode/orderCommit", order_id.ToString());
                foreach(备注图片 rp in orderDto.remarksPicture)
                {
                    String str = FileService.UploadRequest(URL.接口url + "/image/uploadMemoImage?orderId=" + order_id.ToString(), rp.PATH, rp.NAME, "multipartFile");
                }

                //order_id++;
                SQLmtm.DoInsert("o_order_brand_r", new string[] { "OGNIZATION_ID", "SHOP_ID", "BRAND_ID", "ORDER_ID" }, new string[] { "95", "50", "", order_id.ToString() });
            }
            else if (orderDto.orderSalesType == Enum订单类型.样衣订单)
            {
                RestCall.httpGetMethod(URL.接口url + "/barcode/generateOrderInfo?customerId=" + orderDto.customerId + "&styleId=" + orderDto.styleId + "&orderNumber=" + orderDto.orderNumber);
                //RestCall.httpGetMethod("https://shirtmtm.com/fragsmart-mtm/customer/update/payment?styleId=" + orderDto.style_id + "&customerId=" + orderDto.CUSTOMER_ID + "&addressId=" + orderDto.ADDRESS_ID + "&number=" + orderDto.ORDER_NUMBER);
                int order_id = Convert.ToInt32(SQLmtm.GetDataRow("SELECT MAX(ORDER_ID) AS ORDER_ID FROM `o_order_p`")["ORDER_ID"].ToString());
                
                orderDto.build辅料OrderID(order_id.ToString());//注入orderID
                
                String log = RestCall.PostHttp(URL.接口url + "/acc/saveStyleAccessoryItems?orderId="+orderDto.styleAccessoryItemsDTO.orderId+ "&styleName="+orderDto.styleAccessoryItemsDTO.styleName, orderDto.saveStyleAccessoryItemsDTO);
                String orderCommit = RestCall.PostHttp(URL.接口url + "/barcode/orderCommit", order_id.ToString());
                //order_id++;
                SQLmtm.DoInsert("o_order_brand_r", new string[] { "OGNIZATION_ID", "SHOP_ID", "BRAND_ID", "ORDER_ID" }, new string[] { "95", "48", "", order_id.ToString() });

                //样品下单的formId与订单Id关联
                Dictionary<int, string> map = new Dictionary<int, string>();
                map.Add(order_id, orderDto.fromId);
                RestCall.PostHttp(URL.接口url + "/sample/saveOrderSampleRelationIndex",FunctionHelper.JsonSerialization(map));

            }
            else if(orderDto.orderSalesType == Enum订单类型.坚山订单)
            {
                #region o_order_p sql
                String sql = "INSERT INTO `fragsmart-mtm`.`o_order_p` (\n" +
                            "	`OGNIZATION_ID`,\n" +
                            "	`SHOP_ID`,\n" +
                            "	`SHOP_NAME`,\n" +
                            "	`ORDER_NO`,\n" +
                            "	`ORDER_TYPE_CD`,\n" +
                            "	`CUSTOM_ORDER_NO`,\n" +
                            "	`CUSTOM_NAME`,\n" +
                            "	`CUSTOM_MAKE_SHIRT`,\n" +
                            "	`TRANSIT_GROUP`,\n" +
                            "	`COUNTRY`,\n" +
                            "	`SLEEVE_FLAG`,\n" +
                            "	`CUSTOMER_ID`,\n" +
                            "	`CUSTOMER_NAME`,\n" +
                            "	`FACTORY_ID`,\n" +
                            "	`STYLE_ID`,\n" +
                            "	`REF_ORDER_ID`,\n" +
                            "	`SPECIAL_ORDER`,\n" +
                            "	`TRYON_ORDER`,\n" +
                            "	`FIT_STYLE_SIZE`,\n" +
                            "	`TAILOR_ID`,\n" +
                            "	`SHIPPING_DESTINATION`,\n" +
                            "	`ORDER_DATE`,\n" +
                            "	`PAYMENT_DATE`,\n" +
                            "	`PAYMENT_CONFIRM_DATE`,\n" +
                            "	`ORDER_ACCEPT_DATE`,\n" +
                            "	`ORDER_PRO_START_DATE`,\n" +
                            "	`ORDER_PRO_END_DATE`,\n" +
                            "	`ORDER_PACK_DATE`,\n" +
                            "	`ORDER_SHIPMENTS_DATE`,\n" +
                            "	`TARGET_DATE`,\n" +
                            "	`REAL_DATE`,\n" +
                            "	`ORDER_STATUS_CD`,\n" +
                            "	`ORDER_PRODUCE_STATUS_CD`,\n" +
                            "	`ORDER_QC34`,\n" +
                            "	`ORDER_QC35`,\n" +
                            "	`ORDER_QC36`,\n" +
                            "	`ORDER_QC37`,\n" +
                            "	`ORDER_NUMBER`,\n" +
                            "	`ORDER_MATERIAL_COST`,\n" +
                            "	`ORDER_DESIGN_COST`,\n" +
                            "	`ORDER_PROCESS_COST`,\n" +
                            "	`ORDER_PACK_COST`,\n" +
                            "	`ORDER_EXPRESS_COST`,\n" +
                            "	`ORDER_SELL_ACCOUNT`,\n" +
                            "	`ORDER_OTHER_COST`,\n" +
                            "	`MATERIAL_SOURCE`,\n" +
                            "	`URGENT_CD`,\n" +
                            "	`AFTER_SALE_STATUS`,\n" +
                            "	`FIT_COMPLETE_FLAG`,\n" +
                            "	`REMARKS`,\n" +
                            "	`DELETE_FLAG`,\n" +
                            "	`VERSION`,\n" +
                            "	`CREATE_USER`,\n" +
                            "	`UPDATE_USER`,\n" +
                            "	`SEL_KBN`,\n" +
                            "	`ACTUAL_PAYMENT_COST`,\n" +
                            "	`PREFERENTIAL_AMOUNT_COST`,\n" +
                            "	`PREFERENTIAL_PERCENTAGE`,\n" +
                            "	`PRINT_FLAG` \n" +
                            ")\n" +
                            "VALUES\n" +
                            "	(\n" +
                            "		120,\n" +
                            "		46,\n" +
                            "		'KASHIYAMA',\n" +
                            "		'" + FunctionHelper.generateBillNo_坚山("o_order_p", "ORDER_NO", "KA.DL27.", "000000") + "',\n" +
                            "		'ORDER_TYPE-TYPE_20',\n" +
                            "		NULL,\n" +
                            "		'" + orderDto.customerName + "',\n" +
                            "		'4M',\n" +
                            "		NULL,\n" +
                            "		'7',\n" +
                            "		NULL,\n" +
                            "		" + orderDto.customerId + ",\n" +
                            "		'" + orderDto.customerName + "',\n" +
                            "		NULL,\n" +
                            "		" + orderDto.styleId + ",\n" +
                            "		NULL,\n" +
                            "		NULL,\n" +
                            "		'NO',\n" +
                            "		NULL,\n" +
                            "		NULL,\n" +
                            "		NULL,\n" +
                            "		'" + DateTime.Now.ToString() + "',\n" +
                            "		'" + DateTime.Now.ToString() + "',\n" +
                            "		NULL,\n" +
                            "		NULL,\n" +
                            "		NULL,\n" +
                            "		NULL,\n" +
                            "		NULL,\n" +
                            "		NULL,\n" +
                            "		'" + DateTime.Now.AddDays(7).ToString() + "',\n" +
                            "		NULL,\n" +
                            "		'ORDER_STATUS-OS_12',\n" +
                            "		NULL,\n" +
                            "		NULL,\n" +
                            "		NULL,\n" +
                            "		NULL,\n" +
                            "		NULL,\n" +
                            "		" + orderDto.orderNumber + ",\n" +
                            "		NULL,\n" +
                            "		NULL,\n" +
                            "		NULL,\n" +
                            "		0.000,\n" +
                            "		0.000,\n" +
                            "		NULL,\n" +
                            "		0.000,\n" +
                            "		0,\n" +
                            "		'ORDER_FLAG-normal_10',\n" +
                            "		0,\n" +
                            "		0,\n" +
                            "		'" + orderDto.remarks + "',\n" +
                            "		0,\n" +
                            "		1,\n" +
                            "		86,\n" +
                            "		86,\n" +
                            "		0,\n" +
                            "		NULL,\n" +
                            "		NULL,\n" +
                            "		NULL,\n" +
                            "	0 \n" +
                            "	);";
                #endregion
                SQLmtm.ExecuteSql(sql);
                int order_id = Convert.ToInt32(SQLmtm.GetDataRow("SELECT MAX(ORDER_ID) AS ORDER_ID FROM `o_order_p`")["ORDER_ID"].ToString());
                //order_id++;
                SQLmtm.DoInsert("o_order_brand_r", new string[] { "OGNIZATION_ID", "SHOP_ID", "BRAND_ID", "ORDER_ID" }, new string[] { "120", "46", "", order_id.ToString() });
                DataRow addr = SQLmtm.GetDataRow("SELECT\n" +
                                    "	`ADDRESS_ID`,\n" +
                                    "	`CONSIGNEE`,\n" +
                                    "	`ADDRESS_COUNTRY_CD`,\n" +
                                    "	`ADDRESS_PROVINCE_CD`,\n" +
                                    "	`ADDRESS_CITY_CD`,\n" +
                                    "	`ADDRESS_DISTRICT`,\n" +
                                    "	`ADDRESS_DETAIL`,\n" +
                                    "	`ZIP_CODE`,\n" +
                                    "	`MOBILE` \n" +
                                    "FROM\n" +
                                    "	a_customer_address_p \n" +
                                    "WHERE\n" +
                                    "	ADDRESS_ID = '" + orderDto.addressId + "';");
                SQLmtm.ExecuteSql("INSERT INTO `fragsmart-mtm`.`a_kashiyama_address_p` ( `ORDER_ID`, `ADDRESS_ID`, `CONSIGNEE`, `ADDRESS_COUNTRY_CD`, `ADDRESS_PROVINCE_CD`, `ADDRESS_CITY_CD`, `ADDRESS_DISTRICT`, `ADDRESS_DETAIL`, `ZIP_CODE`, `MOBILE` )\n" +
"VALUES\n" +
"	( '" + order_id + "', '" + addr["ADDRESS_ID"].ToString() + "', '" + addr["CONSIGNEE"].ToString() + "', '" + addr["ADDRESS_COUNTRY_CD"].ToString() + "', '" + addr["ADDRESS_PROVINCE_CD"].ToString() + "', '" + addr["ADDRESS_CITY_CD"].ToString() + "', '" + addr["ADDRESS_DISTRICT"].ToString() + "', '" + addr["ADDRESS_DETAIL"].ToString() + "', '" + addr["ZIP_CODE"].ToString() + "', '" + addr["MOBILE"].ToString() + "' );");

                SQLmtm.ExecuteSql("INSERT INTO `fragsmart-mtm`.`a_kashiyama_o` ( `ORDER_ID`, `KUS_ORDER_ID` )\n" +
"VALUES\n" +
"	( '" + order_id.ToString() + "', '" + orderDto.kashiyamaOrderNo + "' );");
            }
            else if (orderDto.orderSalesType == Enum订单类型.坚山美国订单)
            {
                #region o_order_p sql
                String sql = "INSERT INTO `fragsmart-mtm`.`o_order_p` (\n" +
                            "	`OGNIZATION_ID`,\n" +
                            "	`SHOP_ID`,\n" +
                            "	`SHOP_NAME`,\n" +
                            "	`ORDER_NO`,\n" +
                            "	`ORDER_TYPE_CD`,\n" +
                            "	`CUSTOM_ORDER_NO`,\n" +
                            "	`CUSTOM_NAME`,\n" +
                            "	`CUSTOM_MAKE_SHIRT`,\n" +
                            "	`TRANSIT_GROUP`,\n" +
                            "	`COUNTRY`,\n" +
                            "	`SLEEVE_FLAG`,\n" +
                            "	`CUSTOMER_ID`,\n" +
                            "	`CUSTOMER_NAME`,\n" +
                            "	`FACTORY_ID`,\n" +
                            "	`STYLE_ID`,\n" +
                            "	`REF_ORDER_ID`,\n" +
                            "	`SPECIAL_ORDER`,\n" +
                            "	`TRYON_ORDER`,\n" +
                            "	`FIT_STYLE_SIZE`,\n" +
                            "	`TAILOR_ID`,\n" +
                            "	`SHIPPING_DESTINATION`,\n" +
                            "	`ORDER_DATE`,\n" +
                            "	`PAYMENT_DATE`,\n" +
                            "	`PAYMENT_CONFIRM_DATE`,\n" +
                            "	`ORDER_ACCEPT_DATE`,\n" +
                            "	`ORDER_PRO_START_DATE`,\n" +
                            "	`ORDER_PRO_END_DATE`,\n" +
                            "	`ORDER_PACK_DATE`,\n" +
                            "	`ORDER_SHIPMENTS_DATE`,\n" +
                            "	`TARGET_DATE`,\n" +
                            "	`REAL_DATE`,\n" +
                            "	`ORDER_STATUS_CD`,\n" +
                            "	`ORDER_PRODUCE_STATUS_CD`,\n" +
                            "	`ORDER_QC34`,\n" +
                            "	`ORDER_QC35`,\n" +
                            "	`ORDER_QC36`,\n" +
                            "	`ORDER_QC37`,\n" +
                            "	`ORDER_NUMBER`,\n" +
                            "	`ORDER_MATERIAL_COST`,\n" +
                            "	`ORDER_DESIGN_COST`,\n" +
                            "	`ORDER_PROCESS_COST`,\n" +
                            "	`ORDER_PACK_COST`,\n" +
                            "	`ORDER_EXPRESS_COST`,\n" +
                            "	`ORDER_SELL_ACCOUNT`,\n" +
                            "	`ORDER_OTHER_COST`,\n" +
                            "	`MATERIAL_SOURCE`,\n" +
                            "	`URGENT_CD`,\n" +
                            "	`AFTER_SALE_STATUS`,\n" +
                            "	`FIT_COMPLETE_FLAG`,\n" +
                            "	`REMARKS`,\n" +
                            "	`DELETE_FLAG`,\n" +
                            "	`VERSION`,\n" +
                            "	`CREATE_USER`,\n" +
                            "	`UPDATE_USER`,\n" +
                            "	`SEL_KBN`,\n" +
                            "	`ACTUAL_PAYMENT_COST`,\n" +
                            "	`PREFERENTIAL_AMOUNT_COST`,\n" +
                            "	`PREFERENTIAL_PERCENTAGE`,\n" +
                            "	`PRINT_FLAG` \n" +
                            ")\n" +
                            "VALUES\n" +
                            "	(\n" +
                            "		120,\n" +
                            "		49,\n" +
                            "		'KASHIYAMA US',\n" +
                            "		'" + FunctionHelper.generateBillNo_坚山("o_order_p", "ORDER_NO", "KA.DL27.", "000000") + "',\n" +
                            "		'ORDER_TYPE-TYPE_20',\n" +
                            "		NULL,\n" +
                            "		'" + orderDto.customerName + "',\n" +
                            "		'4M',\n" +
                            "		NULL,\n" +
                            "		'7',\n" +
                            "		NULL,\n" +
                            "		" + orderDto.customerId + ",\n" +
                            "		'" + orderDto.customerName + "',\n" +
                            "		NULL,\n" +
                            "		" + orderDto.styleId + ",\n" +
                            "		NULL,\n" +
                            "		NULL,\n" +
                            "		'NO',\n" +
                            "		NULL,\n" +
                            "		NULL,\n" +
                            "		NULL,\n" +
                            "		'" + DateTime.Now.ToString() + "',\n" +
                            "		'" + DateTime.Now.ToString() + "',\n" +
                            "		NULL,\n" +
                            "		NULL,\n" +
                            "		NULL,\n" +
                            "		NULL,\n" +
                            "		NULL,\n" +
                            "		NULL,\n" +
                            "		'" + DateTime.Now.AddDays(7).ToString() + "',\n" +
                            "		NULL,\n" +
                            "		'ORDER_STATUS-OS_12',\n" +
                            "		NULL,\n" +
                            "		NULL,\n" +
                            "		NULL,\n" +
                            "		NULL,\n" +
                            "		NULL,\n" +
                            "		" + orderDto.orderNumber + ",\n" +
                            "		NULL,\n" +
                            "		NULL,\n" +
                            "		NULL,\n" +
                            "		0.000,\n" +
                            "		0.000,\n" +
                            "		NULL,\n" +
                            "		0.000,\n" +
                            "		0,\n" +
                            "		'ORDER_FLAG-normal_10',\n" +
                            "		0,\n" +
                            "		0,\n" +
                            "		'" + orderDto.remarks + "',\n" +
                            "		0,\n" +
                            "		1,\n" +
                            "		86,\n" +
                            "		86,\n" +
                            "		0,\n" +
                            "		NULL,\n" +
                            "		NULL,\n" +
                            "		NULL,\n" +
                            "	0 \n" +
                            "	);";
                #endregion
                SQLmtm.ExecuteSql(sql);
                int order_id = Convert.ToInt32(SQLmtm.GetDataRow("SELECT MAX(ORDER_ID) AS ORDER_ID FROM `o_order_p`")["ORDER_ID"].ToString());
                //order_id++;
                SQLmtm.DoInsert("o_order_brand_r", new string[] { "OGNIZATION_ID", "SHOP_ID", "BRAND_ID", "ORDER_ID" }, new string[] { "120", "49", "", order_id.ToString() });
            }
            else if (orderDto.orderSalesType == Enum订单类型.坚山美国Excel导入订单)
            {
                orderDto.orderNo = FunctionHelper.generateBillNo_坚山("o_order_p", "ORDER_NO", "KA.DL27.", "000000");
                #region o_order_p sql
                String sql = "INSERT INTO `fragsmart-mtm`.`o_order_p` (\n" +
                            "	`OGNIZATION_ID`,\n" +
                            "	`SHOP_ID`,\n" +
                            "	`SHOP_NAME`,\n" +
                            "	`ORDER_NO`,\n" +
                            "	`ORDER_TYPE_CD`,\n" +
                            "	`CUSTOM_ORDER_NO`,\n" +
                            "	`CUSTOM_NAME`,\n" +
                            "	`CUSTOM_MAKE_SHIRT`,\n" +
                            "	`TRANSIT_GROUP`,\n" +
                            "	`COUNTRY`,\n" +
                            "	`SLEEVE_FLAG`,\n" +
                            "	`CUSTOMER_ID`,\n" +
                            "	`CUSTOMER_NAME`,\n" +
                            "	`FACTORY_ID`,\n" +
                            "	`STYLE_ID`,\n" +
                            "	`REF_ORDER_ID`,\n" +
                            "	`SPECIAL_ORDER`,\n" +
                            "	`TRYON_ORDER`,\n" +
                            "	`FIT_STYLE_SIZE`,\n" +
                            "	`TAILOR_ID`,\n" +
                            "	`SHIPPING_DESTINATION`,\n" +
                            "	`ORDER_DATE`,\n" +
                            "	`PAYMENT_DATE`,\n" +
                            "	`PAYMENT_CONFIRM_DATE`,\n" +
                            "	`ORDER_ACCEPT_DATE`,\n" +
                            "	`ORDER_PRO_START_DATE`,\n" +
                            "	`ORDER_PRO_END_DATE`,\n" +
                            "	`ORDER_PACK_DATE`,\n" +
                            "	`ORDER_SHIPMENTS_DATE`,\n" +
                            "	`TARGET_DATE`,\n" +
                            "	`REAL_DATE`,\n" +
                            "	`ORDER_STATUS_CD`,\n" +
                            "	`ORDER_PRODUCE_STATUS_CD`,\n" +
                            "	`ORDER_QC34`,\n" +
                            "	`ORDER_QC35`,\n" +
                            "	`ORDER_QC36`,\n" +
                            "	`ORDER_QC37`,\n" +
                            "	`ORDER_NUMBER`,\n" +
                            "	`ORDER_MATERIAL_COST`,\n" +
                            "	`ORDER_DESIGN_COST`,\n" +
                            "	`ORDER_PROCESS_COST`,\n" +
                            "	`ORDER_PACK_COST`,\n" +
                            "	`ORDER_EXPRESS_COST`,\n" +
                            "	`ORDER_SELL_ACCOUNT`,\n" +
                            "	`ORDER_OTHER_COST`,\n" +
                            "	`MATERIAL_SOURCE`,\n" +
                            "	`URGENT_CD`,\n" +
                            "	`AFTER_SALE_STATUS`,\n" +
                            "	`FIT_COMPLETE_FLAG`,\n" +
                            "	`REMARKS`,\n" +
                            "	`DELETE_FLAG`,\n" +
                            "	`VERSION`,\n" +
                            "	`CREATE_USER`,\n" +
                            "	`UPDATE_USER`,\n" +
                            "	`SEL_KBN`,\n" +
                            "	`ACTUAL_PAYMENT_COST`,\n" +
                            "	`PREFERENTIAL_AMOUNT_COST`,\n" +
                            "	`PREFERENTIAL_PERCENTAGE`,\n" +
                            "	`PRINT_FLAG` \n" +
                            ")\n" +
                            "VALUES\n" +
                            "	(\n" +
                            "		120,\n" +
                            "		49,\n" +
                            "		'KASHIYAMA US',\n" +
                            "		'" + orderDto.orderNo + "',\n" +
                            "		'ORDER_TYPE-TYPE_20',\n" +
                            "		NULL,\n" +
                            "		'" + orderDto.customerName + "',\n" +
                            "		'4M',\n" +
                            "		NULL,\n" +
                            "		'7',\n" +
                            "		NULL,\n" +
                            "		" + orderDto.customerId + ",\n" +
                            "		'" + orderDto.customerName + "',\n" +
                            "		NULL,\n" +
                            "		" + orderDto.styleId + ",\n" +
                            "		NULL,\n" +
                            "		NULL,\n" +
                            "		'NO',\n" +
                            "		NULL,\n" +
                            "		NULL,\n" +
                            "		NULL,\n" +
                            "		'" + DateTime.Now.ToString() + "',\n" +
                            "		'" + DateTime.Now.ToString() + "',\n" +
                            "		NULL,\n" +
                            "		NULL,\n" +
                            "		NULL,\n" +
                            "		NULL,\n" +
                            "		NULL,\n" +
                            "		NULL,\n" +
                            "		'" + DateTime.Now.AddDays(7).ToString() + "',\n" +
                            "		NULL,\n" +
                            "		'ORDER_STATUS-OS_12',\n" +
                            "		NULL,\n" +
                            "		NULL,\n" +
                            "		NULL,\n" +
                            "		NULL,\n" +
                            "		NULL,\n" +
                            "		" + orderDto.orderNumber + ",\n" +
                            "		NULL,\n" +
                            "		NULL,\n" +
                            "		NULL,\n" +
                            "		0.000,\n" +
                            "		0.000,\n" +
                            "		NULL,\n" +
                            "		0.000,\n" +
                            "		0,\n" +
                            "		'ORDER_FLAG-normal_10',\n" +
                            "		0,\n" +
                            "		0,\n" +
                            "		'" + orderDto.remarks + "',\n" +
                            "		0,\n" +
                            "		1,\n" +
                            "		86,\n" +
                            "		86,\n" +
                            "		0,\n" +
                            "		NULL,\n" +
                            "		NULL,\n" +
                            "		NULL,\n" +
                            "	0 \n" +
                            "	);";
                #endregion
                SQLmtm.ExecuteSql(sql);
                int order_id = Convert.ToInt32(SQLmtm.GetDataRow("SELECT MAX(ORDER_ID) AS ORDER_ID FROM `o_order_p`")["ORDER_ID"].ToString());
                //order_id++;
                SQLmtm.DoInsert("o_order_brand_r", new string[] { "OGNIZATION_ID", "SHOP_ID", "BRAND_ID", "ORDER_ID" }, new string[] { "120", "49", "", order_id.ToString() });
                orderDto.OrderReceiptData.buildOrderNo(orderDto.orderNo);
                String jsonkashiyamaSizeFitDTOs = FunctionHelper.JsonSerialization(orderDto.dtoSize.kashiyamaSizeFitDTOs);
                RestCall.PostHttp(URL.接口url + "/kashiyamaUS/saveKashiyamaOrderFitIndex?orderId=" + order_id + "&orderNo=" + orderDto.orderNo + "&kashiyamaOrderNo=" + orderDto.kashiyamaOrderNo, jsonkashiyamaSizeFitDTOs);
            }
            //DataRow ORDER_ID = SQLmtm.GetDataRow("SELECT MAX(ORDER_ID) AS ORDER_ID FROM `o_order_p`");
            //int order_id = Convert.ToInt32(ORDER_ID["ORDER_ID"]);
            //order_id++;
            //SQLmtm.DoInsert("o_order_brand_r", new string[] { "OGNIZATION_ID", "SHOP_ID", "BRAND_ID", "ORDER_ID" }, new string[] { "95", "18", "", order_id.ToString() });
            //SQLmtm.DoInsert("t_order_type", new string[] { "ORDER_ID", "ORDER_TYPE" }, new string[] { order_id.ToString(), "1" });
        }

        public static DataTable get订单ByORDER_NO(String ORDER_NO)
        {
            String sql = "SELECT\n" +
                    "	s_style_p.STYLE_NAME_CN,\n" +
                    "	s_style_p.STYLE_FIT_CD,\n" +
                    "	s_style_p.STYLE_CATEGORY_CD,\n" +
                    "	s_style_p.STYLE_SIZE_CD,\n" +
                    "	s_style_p.STYLE_SIZE_GROUP_CD,\n" +
                    "	o_order_p.ORDER_ID,\n" +
                    "	o_order_p.OGNIZATION_ID,\n" +
                    "	o_order_p.SHOP_ID,\n" +
                    "	o_order_p.SHOP_NAME,\n" +
                    "	o_order_p.ORDER_NO,\n" +
                    "	o_order_p.ORDER_TYPE_CD,\n" +
                    "	o_order_p.CUSTOM_ORDER_NO,\n" +
                    "	o_order_p.CUSTOM_NAME,\n" +
                    "	o_order_p.CUSTOM_MAKE_SHIRT,\n" +
                    "	o_order_p.TRANSIT_GROUP,\n" +
                    "	o_order_p.COUNTRY,\n" +
                    "	o_order_p.SLEEVE_FLAG,\n" +
                    "	o_order_p.CUSTOMER_ID,\n" +
                    "	o_order_p.CUSTOMER_NAME,\n" +
                    "	o_order_p.FACTORY_ID,\n" +
                    "	o_order_p.STYLE_ID,\n" +
                    "	o_order_p.REF_ORDER_ID,\n" +
                    "	o_order_p.SPECIAL_ORDER,\n" +
                    "	o_order_p.TRYON_ORDER,\n" +
                    "	o_order_p.FIT_STYLE_SIZE,\n" +
                    "	o_order_p.TAILOR_ID,\n" +
                    "	o_order_p.SHIPPING_DESTINATION,\n" +
                    "	o_order_p.PAYMENT_DATE,\n" +
                    "	o_order_p.PAYMENT_CONFIRM_DATE,\n" +
                    "	o_order_p.ORDER_ACCEPT_DATE,\n" +
                    "	o_order_p.ORDER_PRO_START_DATE,\n" +
                    "	o_order_p.ORDER_PRO_END_DATE,\n" +
                    "	o_order_p.ORDER_PACK_DATE,\n" +
                    "	o_order_p.ORDER_SHIPMENTS_DATE,\n" +
                    "	o_order_p.TARGET_DATE,\n" +
                    "	o_order_p.REAL_DATE,\n" +
                    "	o_order_p.ORDER_STATUS_CD,\n" +
                    "	ORDER_STATUS.ITEM_NAME_CN,\n" +
                    "	o_order_p.ORDER_PRODUCE_STATUS_CD,\n" +
                    "	o_order_p.ORDER_QC34,\n" +
                    "	o_order_p.ORDER_QC35,\n" +
                    "	o_order_p.ORDER_QC36,\n" +
                    "	o_order_p.ORDER_QC37,\n" +
                    "	o_order_p.ORDER_NUMBER,\n" +
                    "	o_order_p.ORDER_MATERIAL_COST,\n" +
                    "	o_order_p.ORDER_DESIGN_COST,\n" +
                    "	o_order_p.ORDER_PROCESS_COST,\n" +
                    "	o_order_p.ORDER_PACK_COST,\n" +
                    "	o_order_p.ORDER_EXPRESS_COST,\n" +
                    "	o_order_p.ORDER_SELL_ACCOUNT,\n" +
                    "	o_order_p.ORDER_OTHER_COST,\n" +
                    "	o_order_p.MATERIAL_SOURCE,\n" +
                    "	o_order_p.URGENT_CD,\n" +
                    "	o_order_p.AFTER_SALE_STATUS,\n" +
                    "	o_order_p.FIT_COMPLETE_FLAG,\n" +
                    "	o_order_p.REMARKS,\n" +
                    "	o_order_p.DELETE_FLAG,\n" +
                    "	o_order_p.VERSION,\n" +
                    "	o_order_p.CREATE_DATE,\n" +
                    "	o_order_p.UPDATE_DATE,\n" +
                    "	o_order_p.CREATE_USER,\n" +
                    "	o_order_p.UPDATE_USER,\n" +
                    "	o_order_p.SEL_KBN,\n" +
                    "	o_order_p.ACTUAL_PAYMENT_COST,\n" +
                    "	o_order_p.PREFERENTIAL_AMOUNT_COST,\n" +
                    "	o_order_p.PREFERENTIAL_PERCENTAGE,\n" +
                    "	DATE_FORMAT( o_order_p.ORDER_DATE, '%Y-%m-%d' ) AS ORDER_DATE,\n" +
                    "	print_flag.ITEM_NAME_CN AS PRINT_STATUS,\n" +
                    "	fr.BUSINESS_NO,\n" +
                    "	fc.CUSTOMER_NAME AS CUSTOMER_TRUE_NAME,\n" +
                    "	customer.MOBILE,\n" +
                    "	SUBSTRING_INDEX( s_style_p.STYLE_SIZE_CD, '-',- 1 ) AS SIZE \n" +
                    "FROM\n" +
                    "	o_order_p\n" +
                    "	LEFT JOIN s_style_p ON o_order_p.STYLE_ID = s_style_p.SYS_STYLE_ID\n" +
                    "	LEFT JOIN ( SELECT CONCAT( ITEM_CD, '-', ITEM_VALUE ) AS ITEM_VALUE, ITEM_NAME_CN FROM a_dict_p WHERE item_cd LIKE 'ORDER_STATUS' ) ORDER_STATUS ON ORDER_STATUS.ITEM_VALUE = o_order_p.ORDER_STATUS_CD\n" +
                    "	LEFT JOIN ( SELECT ITEM_NAME_CN, ITEM_VALUE FROM a_dict_p WHERE ITEM_CD = 'ORDER_PRINT_STATUS' ) print_flag ON o_order_p.PRINT_FLAG = print_flag.ITEM_VALUE\n" +
                    "	LEFT JOIN f_accounting_order_r fr ON o_order_p.ORDER_ID = fr.ORDER_ID\n" +
                    "	LEFT JOIN a_customer_fit_count_r fc ON fc.ID = s_style_p.CUSTOMER_COUNT_ID\n" +
                    "	LEFT JOIN a_customer_p customer ON o_order_p.CUSTOMER_ID = customer.CUSTOMER_ID \n" +
                    "WHERE\n" +
                    "	o_order_p.ORDER_NO = ('" + ORDER_NO + "') \n" +
                    "	-- AND o_order_p.SHOP_ID = '18' \n" +
                    "ORDER BY\n" +
                    "	o_order_p.order_date DESC";
            return SQLmtm.GetDataTable(sql);
        }
        public static DataTable get坚山订单ByCUSTOMER_NAME(String CUSTOMER_NAME)
        {
            String sql = "SELECT\n" +
                    "	s_style_p.STYLE_NAME_CN,\n" +
                    "	s_style_p.STYLE_FIT_CD,\n" +
                    "	s_style_p.STYLE_CATEGORY_CD,\n" +
                    "	s_style_p.STYLE_SIZE_CD,\n" +
                    "	s_style_p.STYLE_SIZE_GROUP_CD,\n" +
                    "	o_order_p.ORDER_ID,\n" +
                    "	o_order_p.OGNIZATION_ID,\n" +
                    "	o_order_p.SHOP_ID,\n" +
                    "	o_order_p.SHOP_NAME,\n" +
                    "	o_order_p.ORDER_NO,\n" +
                    "	o_order_p.ORDER_TYPE_CD,\n" +
                    "	o_order_p.CUSTOM_ORDER_NO,\n" +
                    "	o_order_p.CUSTOM_NAME,\n" +
                    "	o_order_p.CUSTOM_MAKE_SHIRT,\n" +
                    "	o_order_p.TRANSIT_GROUP,\n" +
                    "	o_order_p.COUNTRY,\n" +
                    "	o_order_p.SLEEVE_FLAG,\n" +
                    "	o_order_p.CUSTOMER_ID,\n" +
                    "	o_order_p.CUSTOMER_NAME,\n" +
                    "	o_order_p.FACTORY_ID,\n" +
                    "	o_order_p.STYLE_ID,\n" +
                    "	o_order_p.REF_ORDER_ID,\n" +
                    "	o_order_p.SPECIAL_ORDER,\n" +
                    "	o_order_p.TRYON_ORDER,\n" +
                    "	o_order_p.FIT_STYLE_SIZE,\n" +
                    "	o_order_p.TAILOR_ID,\n" +
                    "	o_order_p.SHIPPING_DESTINATION,\n" +
                    "	o_order_p.PAYMENT_DATE,\n" +
                    "	o_order_p.PAYMENT_CONFIRM_DATE,\n" +
                    "	o_order_p.ORDER_ACCEPT_DATE,\n" +
                    "	o_order_p.ORDER_PRO_START_DATE,\n" +
                    "	o_order_p.ORDER_PRO_END_DATE,\n" +
                    "	o_order_p.ORDER_PACK_DATE,\n" +
                    "	o_order_p.ORDER_SHIPMENTS_DATE,\n" +
                    "	o_order_p.TARGET_DATE,\n" +
                    "	o_order_p.REAL_DATE,\n" +
                    "	o_order_p.ORDER_STATUS_CD,\n" +
                    "	ORDER_STATUS.ITEM_NAME_CN,\n" +
                    "	o_order_p.ORDER_PRODUCE_STATUS_CD,\n" +
                    "	o_order_p.ORDER_QC34,\n" +
                    "	o_order_p.ORDER_QC35,\n" +
                    "	o_order_p.ORDER_QC36,\n" +
                    "	o_order_p.ORDER_QC37,\n" +
                    "	o_order_p.ORDER_NUMBER,\n" +
                    "	o_order_p.ORDER_MATERIAL_COST,\n" +
                    "	o_order_p.ORDER_DESIGN_COST,\n" +
                    "	o_order_p.ORDER_PROCESS_COST,\n" +
                    "	o_order_p.ORDER_PACK_COST,\n" +
                    "	o_order_p.ORDER_EXPRESS_COST,\n" +
                    "	o_order_p.ORDER_SELL_ACCOUNT,\n" +
                    "	o_order_p.ORDER_OTHER_COST,\n" +
                    "	o_order_p.MATERIAL_SOURCE,\n" +
                    "	o_order_p.URGENT_CD,\n" +
                    "	o_order_p.AFTER_SALE_STATUS,\n" +
                    "	o_order_p.FIT_COMPLETE_FLAG,\n" +
                    "	o_order_p.REMARKS,\n" +
                    "	o_order_p.DELETE_FLAG,\n" +
                    "	o_order_p.VERSION,\n" +
                    "	o_order_p.CREATE_DATE,\n" +
                    "	o_order_p.UPDATE_DATE,\n" +
                    "	o_order_p.CREATE_USER,\n" +
                    "	o_order_p.UPDATE_USER,\n" +
                    "	o_order_p.SEL_KBN,\n" +
                    "	o_order_p.ACTUAL_PAYMENT_COST,\n" +
                    "	o_order_p.PREFERENTIAL_AMOUNT_COST,\n" +
                    "	o_order_p.PREFERENTIAL_PERCENTAGE,\n" +
                    "	DATE_FORMAT( o_order_p.ORDER_DATE, '%Y-%m-%d' ) AS ORDER_DATE,\n" +
                    "	print_flag.ITEM_NAME_CN AS PRINT_STATUS,\n" +
                    "	fr.BUSINESS_NO,\n" +
                    "	fc.CUSTOMER_NAME AS CUSTOMER_TRUE_NAME,\n" +
                    "	customer.MOBILE,\n" +
                    "	SUBSTRING_INDEX( s_style_p.STYLE_SIZE_CD, '-',- 1 ) AS SIZE \n" +
                    "FROM\n" +
                    "	o_order_p\n" +
                    "	LEFT JOIN s_style_p ON o_order_p.STYLE_ID = s_style_p.SYS_STYLE_ID\n" +
                    "	LEFT JOIN ( SELECT CONCAT( ITEM_CD, '-', ITEM_VALUE ) AS ITEM_VALUE, ITEM_NAME_CN FROM a_dict_p WHERE item_cd LIKE 'ORDER_STATUS' ) ORDER_STATUS ON ORDER_STATUS.ITEM_VALUE = o_order_p.ORDER_STATUS_CD\n" +
                    "	LEFT JOIN ( SELECT ITEM_NAME_CN, ITEM_VALUE FROM a_dict_p WHERE ITEM_CD = 'ORDER_PRINT_STATUS' ) print_flag ON o_order_p.PRINT_FLAG = print_flag.ITEM_VALUE\n" +
                    "	LEFT JOIN f_accounting_order_r fr ON o_order_p.ORDER_ID = fr.ORDER_ID\n" +
                    "	LEFT JOIN a_customer_fit_count_r fc ON fc.ID = s_style_p.CUSTOMER_COUNT_ID\n" +
                    "	LEFT JOIN a_customer_p customer ON o_order_p.CUSTOMER_ID = customer.CUSTOMER_ID \n" +
                    "WHERE\n" +
                    "o_order_p.SHOP_ID=46\n" +
                    "	and o_order_p.CUSTOMER_NAME like \"%" + CUSTOMER_NAME + "%\"" +
                    "ORDER BY\n" +
                    "	o_order_p.order_date DESC";
            return SQLmtm.GetDataTable(sql);
        }

        public static DataTable get坚山订单sByOrderN0s(List<String> OrderN0s)
        {
            String sql = "SELECT\n" +
                    "	s_style_p.STYLE_NAME_CN,\n" +
                    "	s_style_p.STYLE_FIT_CD,\n" +
                    "	s_style_p.STYLE_CATEGORY_CD,\n" +
                    "	s_style_p.STYLE_SIZE_CD,\n" +
                    "	s_style_p.STYLE_SIZE_GROUP_CD,\n" +
                    "	o_order_p.ORDER_ID,\n" +
                    "	o_order_p.OGNIZATION_ID,\n" +
                    "	o_order_p.SHOP_ID,\n" +
                    "	o_order_p.SHOP_NAME,\n" +
                    "	o_order_p.ORDER_NO,\n" +
                    "	o_order_p.ORDER_TYPE_CD,\n" +
                    "	o_order_p.CUSTOM_ORDER_NO,\n" +
                    "	o_order_p.CUSTOM_NAME,\n" +
                    "	o_order_p.CUSTOM_MAKE_SHIRT,\n" +
                    "	o_order_p.TRANSIT_GROUP,\n" +
                    "	o_order_p.COUNTRY,\n" +
                    "	o_order_p.SLEEVE_FLAG,\n" +
                    "	o_order_p.CUSTOMER_ID,\n" +
                    "	o_order_p.CUSTOMER_NAME,\n" +
                    "	o_order_p.FACTORY_ID,\n" +
                    "	o_order_p.STYLE_ID,\n" +
                    "	o_order_p.REF_ORDER_ID,\n" +
                    "	o_order_p.SPECIAL_ORDER,\n" +
                    "	o_order_p.TRYON_ORDER,\n" +
                    "	o_order_p.FIT_STYLE_SIZE,\n" +
                    "	o_order_p.TAILOR_ID,\n" +
                    "	o_order_p.SHIPPING_DESTINATION,\n" +
                    "	o_order_p.PAYMENT_DATE,\n" +
                    "	o_order_p.PAYMENT_CONFIRM_DATE,\n" +
                    "	o_order_p.ORDER_ACCEPT_DATE,\n" +
                    "	o_order_p.ORDER_PRO_START_DATE,\n" +
                    "	o_order_p.ORDER_PRO_END_DATE,\n" +
                    "	o_order_p.ORDER_PACK_DATE,\n" +
                    "	o_order_p.ORDER_SHIPMENTS_DATE,\n" +
                    "	o_order_p.TARGET_DATE,\n" +
                    "	o_order_p.REAL_DATE,\n" +
                    "	o_order_p.ORDER_STATUS_CD,\n" +
                    "	ORDER_STATUS.ITEM_NAME_CN,\n" +
                    "	o_order_p.ORDER_PRODUCE_STATUS_CD,\n" +
                    "	o_order_p.ORDER_QC34,\n" +
                    "	o_order_p.ORDER_QC35,\n" +
                    "	o_order_p.ORDER_QC36,\n" +
                    "	o_order_p.ORDER_QC37,\n" +
                    "	o_order_p.ORDER_NUMBER,\n" +
                    "	o_order_p.ORDER_MATERIAL_COST,\n" +
                    "	o_order_p.ORDER_DESIGN_COST,\n" +
                    "	o_order_p.ORDER_PROCESS_COST,\n" +
                    "	o_order_p.ORDER_PACK_COST,\n" +
                    "	o_order_p.ORDER_EXPRESS_COST,\n" +
                    "	o_order_p.ORDER_SELL_ACCOUNT,\n" +
                    "	o_order_p.ORDER_OTHER_COST,\n" +
                    "	o_order_p.MATERIAL_SOURCE,\n" +
                    "	o_order_p.URGENT_CD,\n" +
                    "	o_order_p.AFTER_SALE_STATUS,\n" +
                    "	o_order_p.FIT_COMPLETE_FLAG,\n" +
                    "	o_order_p.REMARKS,\n" +
                    "	o_order_p.DELETE_FLAG,\n" +
                    "	o_order_p.VERSION,\n" +
                    "	o_order_p.CREATE_DATE,\n" +
                    "	o_order_p.UPDATE_DATE,\n" +
                    "	o_order_p.CREATE_USER,\n" +
                    "	o_order_p.UPDATE_USER,\n" +
                    "	o_order_p.SEL_KBN,\n" +
                    "	o_order_p.ACTUAL_PAYMENT_COST,\n" +
                    "	o_order_p.PREFERENTIAL_AMOUNT_COST,\n" +
                    "	o_order_p.PREFERENTIAL_PERCENTAGE,\n" +
                    "	DATE_FORMAT( o_order_p.ORDER_DATE, '%Y-%m-%d' ) AS ORDER_DATE,\n" +
                    "	print_flag.ITEM_NAME_CN AS PRINT_STATUS,\n" +
                    "	fr.BUSINESS_NO,\n" +
                    "	fc.CUSTOMER_NAME AS CUSTOMER_TRUE_NAME,\n" +
                    "	customer.MOBILE,\n" +
                    "	SUBSTRING_INDEX( s_style_p.STYLE_SIZE_CD, '-',- 1 ) AS SIZE \n" +
                    "FROM\n" +
                    "	o_order_p\n" +
                    "	LEFT JOIN s_style_p ON o_order_p.STYLE_ID = s_style_p.SYS_STYLE_ID\n" +
                    "	LEFT JOIN ( SELECT CONCAT( ITEM_CD, '-', ITEM_VALUE ) AS ITEM_VALUE, ITEM_NAME_CN FROM a_dict_p WHERE item_cd LIKE 'ORDER_STATUS' ) ORDER_STATUS ON ORDER_STATUS.ITEM_VALUE = o_order_p.ORDER_STATUS_CD\n" +
                    "	LEFT JOIN ( SELECT ITEM_NAME_CN, ITEM_VALUE FROM a_dict_p WHERE ITEM_CD = 'ORDER_PRINT_STATUS' ) print_flag ON o_order_p.PRINT_FLAG = print_flag.ITEM_VALUE\n" +
                    "	LEFT JOIN f_accounting_order_r fr ON o_order_p.ORDER_ID = fr.ORDER_ID\n" +
                    "	LEFT JOIN a_customer_fit_count_r fc ON fc.ID = s_style_p.CUSTOMER_COUNT_ID\n" +
                    "	LEFT JOIN a_customer_p customer ON o_order_p.CUSTOMER_ID = customer.CUSTOMER_ID \n" +
                    "WHERE\n" +
                    "o_order_p.SHOP_ID=46\n" +
                    "	and o_order_p.ORDER_NO in ('"+ String.Join("','",OrderN0s) + "')" +
                    "ORDER BY\n" +
                    "	o_order_p.order_date DESC";
            return SQLmtm.GetDataTable(sql);
        }
        public static DataTable get订单(List<String> status) {
            String str;
            if (status == null || status.Count == 0) {
                throw new Exception("请选择订单状态");
            }
            else if (status.Count == 1) {
                str = status[0];
            }
            else {
                str = String.Join("','", status);
            }

            String sql = "SELECT\n" +
                    "	s_style_p.STYLE_NAME_CN,\n" +
                    "	s_style_p.STYLE_FIT_CD,\n" +
                    "	s_style_p.STYLE_CATEGORY_CD,\n" +
                    "	s_style_p.STYLE_SIZE_CD,\n" +
                    "	s_style_p.STYLE_SIZE_GROUP_CD,\n" +
                    "	o_order_p.ORDER_ID,\n" +
                    "	o_order_p.OGNIZATION_ID,\n" +
                    "	o_order_p.SHOP_ID,\n" +
                    "	o_order_p.SHOP_NAME,\n" +
                    "	o_order_p.ORDER_NO,\n" +
                    "	o_order_p.ORDER_TYPE_CD,\n" +
                    "	o_order_p.CUSTOM_ORDER_NO,\n" +
                    "	o_order_p.CUSTOM_NAME,\n" +
                    "	o_order_p.CUSTOM_MAKE_SHIRT,\n" +
                    "	o_order_p.TRANSIT_GROUP,\n" +
                    "	o_order_p.COUNTRY,\n" +
                    "	o_order_p.SLEEVE_FLAG,\n" +
                    "	o_order_p.CUSTOMER_ID,\n" +
                    "	o_order_p.CUSTOMER_NAME,\n" +
                    "	o_order_p.FACTORY_ID,\n" +
                    "	o_order_p.STYLE_ID,\n" +
                    "	o_order_p.REF_ORDER_ID,\n" +
                    "	o_order_p.SPECIAL_ORDER,\n" +
                    "	o_order_p.TRYON_ORDER,\n" +
                    "	o_order_p.FIT_STYLE_SIZE,\n" +
                    "	o_order_p.TAILOR_ID,\n" +
                    "	o_order_p.SHIPPING_DESTINATION,\n" +
                    "	o_order_p.PAYMENT_DATE,\n" +
                    "	o_order_p.PAYMENT_CONFIRM_DATE,\n" +
                    "	o_order_p.ORDER_ACCEPT_DATE,\n" +
                    "	o_order_p.ORDER_PRO_START_DATE,\n" +
                    "	o_order_p.ORDER_PRO_END_DATE,\n" +
                    "	o_order_p.ORDER_PACK_DATE,\n" +
                    "	o_order_p.ORDER_SHIPMENTS_DATE,\n" +
                    "	o_order_p.TARGET_DATE,\n" +
                    "	o_order_p.REAL_DATE,\n" +
                    "	o_order_p.ORDER_STATUS_CD,\n" +
                    "	t_order_status_p.ORDER_STATUS AS ITEM_NAME_CN,\n" +
                    "	o_order_p.ORDER_PRODUCE_STATUS_CD,\n" +
                    "	o_order_p.ORDER_QC34,\n" +
                    "	o_order_p.ORDER_QC35,\n" +
                    "	o_order_p.ORDER_QC36,\n" +
                    "	o_order_p.ORDER_QC37,\n" +
                    "	o_order_p.ORDER_NUMBER,\n" +
                    "	o_order_p.ORDER_MATERIAL_COST,\n" +
                    "	o_order_p.ORDER_DESIGN_COST,\n" +
                    "	o_order_p.ORDER_PROCESS_COST,\n" +
                    "	o_order_p.ORDER_PACK_COST,\n" +
                    "	o_order_p.ORDER_EXPRESS_COST,\n" +
                    "	o_order_p.ORDER_SELL_ACCOUNT,\n" +
                    "	o_order_p.ORDER_OTHER_COST,\n" +
                    "	o_order_p.MATERIAL_SOURCE,\n" +
                    "	o_order_p.URGENT_CD,\n" +
                    "	o_order_p.AFTER_SALE_STATUS,\n" +
                    "	o_order_p.FIT_COMPLETE_FLAG,\n" +
                    "	o_order_p.REMARKS,\n" +
                    "	o_order_p.DELETE_FLAG,\n" +
                    "	o_order_p.VERSION,\n" +
                    "	o_order_p.CREATE_DATE,\n" +
                    "	o_order_p.UPDATE_DATE,\n" +
                    "	o_order_p.CREATE_USER,\n" +
                    "	o_order_p.UPDATE_USER,\n" +
                    "	o_order_p.SEL_KBN,\n" +
                    "	o_order_p.ACTUAL_PAYMENT_COST,\n" +
                    "	o_order_p.PREFERENTIAL_AMOUNT_COST,\n" +
                    "	o_order_p.PREFERENTIAL_PERCENTAGE,\n" +
                    "	DATE_FORMAT( o_order_p.ORDER_DATE, '%Y-%m-%d' ) AS ORDER_DATE,\n" +
                    "	print_flag.ITEM_NAME_CN AS PRINT_STATUS,\n" +
                    "	fr.BUSINESS_NO,\n" +
                    "	fc.CUSTOMER_NAME AS CUSTOMER_TRUE_NAME,\n" +
                    "	customer.MOBILE,\n" +
                    "	SUBSTRING_INDEX( s_style_p.STYLE_SIZE_CD, '-',- 1 ) AS SIZE, \n" +
                    "a_customer_address_p.CONSIGNEE AS `收货人姓名`,\n" +
                    "	CONCAT( a_customer_address_p.ADDRESS_PROVINCE_CD, a_customer_address_p.ADDRESS_CITY_CD, a_customer_address_p.ADDRESS_DISTRICT, a_customer_address_p.ADDRESS_DETAIL ) AS `收货人地址`,\n" +
                    "	a_customer_address_p.MOBILE AS `收货人电话`, \n" +
                    "  CONCAT(i_material_p.MATERIAL_CODE,i_material_p.MATERIAL_NAME_CN) AS MATERIAL_NAME_CN\n" +
                    "FROM\n" +
                    "(select * from o_order_p where DATE_SUB(CURDATE(), INTERVAL 30 DAY) <= date(CREATE_DATE)) o_order_p "+
                    "	LEFT JOIN s_style_p ON o_order_p.STYLE_ID = s_style_p.SYS_STYLE_ID\n" +
                    "	LEFT JOIN ( SELECT CONCAT( ITEM_CD, '-', ITEM_VALUE ) AS ITEM_VALUE, ITEM_NAME_CN FROM a_dict_p WHERE item_cd LIKE 'ORDER_STATUS' ) ORDER_STATUS ON ORDER_STATUS.ITEM_VALUE = o_order_p.ORDER_STATUS_CD\n" +
                    "	LEFT JOIN ( SELECT ITEM_NAME_CN, ITEM_VALUE FROM a_dict_p WHERE ITEM_CD = 'ORDER_PRINT_STATUS' ) print_flag ON o_order_p.PRINT_FLAG = print_flag.ITEM_VALUE\n" +
                    "	LEFT JOIN f_accounting_order_r fr ON o_order_p.ORDER_ID = fr.ORDER_ID\n" +
                    "	LEFT JOIN a_customer_fit_count_r fc ON fc.ID = s_style_p.CUSTOMER_COUNT_ID\n" +
                    "	LEFT JOIN a_customer_p customer ON o_order_p.CUSTOMER_ID = customer.CUSTOMER_ID \n" +
                    "	LEFT JOIN t_order_status_p ON o_order_p.ORDER_ID = t_order_status_p.ORDER_ID \n" +
                     "	LEFT JOIN (SELECT * FROM a_customer_address_p WHERE DEFAULT_ADDR_FLAG='1') a_customer_address_p ON o_order_p .CUSTOMER_ID=a_customer_address_p.CUSTOMER_ID \n" +
                     "  LEFT JOIN i_material_p ON s_style_p.SYTLE_FABRIC_ID=i_material_p.MATERIAL_ID \n" +
                    "WHERE\n" +
                    "	o_order_p.ORDER_STATUS_CD IN ('" + str + "') \n" +
                    "   -- AND o_order_p.ORDER_ID IN ( SELECT ORDER_ID FROM o_order_brand_r WHERE SHOP_ID = '18' ) \n" +
                    "   AND o_order_p.ORDER_ID NOT IN ( SELECT ORDER_ID FROM o_order_brand_r WHERE SHOP_ID in ( '48','50' ) ) \n" +
                    "	AND o_order_p.SHOP_ID = '18' \n" +
                    "	AND o_order_p.DELETE_FLAG = 0 \n" +
                    "ORDER BY\n" +
                    "	o_order_p.order_date DESC";
            return SQLmtm.GetDataTable(sql);
        }
        public static DataTable Get套号订单(List<String> status)
        {
            String str;
            if (status == null || status.Count == 0)
            {
                throw new Exception("请选择订单状态");
            }
            else if (status.Count == 1)
            {
                str = status[0];
            }
            else
            {
                str = String.Join("','", status);
            }

            String sql = "SELECT\n" +
                    "	s_style_p.STYLE_NAME_CN,\n" +
                    "	s_style_p.STYLE_FIT_CD,\n" +
                    "	s_style_p.STYLE_CATEGORY_CD,\n" +
                    "	s_style_p.STYLE_SIZE_CD,\n" +
                    "	s_style_p.STYLE_SIZE_GROUP_CD,\n" +
                    "	o_order_p.ORDER_ID,\n" +
                    "	o_order_p.OGNIZATION_ID,\n" +
                    "	o_order_p.SHOP_ID,\n" +
                    "	o_order_p.SHOP_NAME,\n" +
                    "	o_order_p.ORDER_NO,\n" +
                    "	o_order_p.ORDER_TYPE_CD,\n" +
                    "	o_order_p.CUSTOM_ORDER_NO,\n" +
                    "	o_order_p.CUSTOM_NAME,\n" +
                    "	o_order_p.CUSTOM_MAKE_SHIRT,\n" +
                    "	o_order_p.TRANSIT_GROUP,\n" +
                    "	o_order_p.COUNTRY,\n" +
                    "	o_order_p.SLEEVE_FLAG,\n" +
                    "	o_order_p.CUSTOMER_ID,\n" +
                    "	o_order_p.CUSTOMER_NAME,\n" +
                    "	o_order_p.FACTORY_ID,\n" +
                    "	o_order_p.STYLE_ID,\n" +
                    "	o_order_p.REF_ORDER_ID,\n" +
                    "	o_order_p.SPECIAL_ORDER,\n" +
                    "	o_order_p.TRYON_ORDER,\n" +
                    "	o_order_p.FIT_STYLE_SIZE,\n" +
                    "	o_order_p.TAILOR_ID,\n" +
                    "	o_order_p.SHIPPING_DESTINATION,\n" +
                    "	o_order_p.PAYMENT_DATE,\n" +
                    "	o_order_p.PAYMENT_CONFIRM_DATE,\n" +
                    "	o_order_p.ORDER_ACCEPT_DATE,\n" +
                    "	o_order_p.ORDER_PRO_START_DATE,\n" +
                    "	o_order_p.ORDER_PRO_END_DATE,\n" +
                    "	o_order_p.ORDER_PACK_DATE,\n" +
                    "	o_order_p.ORDER_SHIPMENTS_DATE,\n" +
                    "	o_order_p.TARGET_DATE,\n" +
                    "	o_order_p.REAL_DATE,\n" +
                    "	o_order_p.ORDER_STATUS_CD,\n" +
                    "	ORDER_STATUS.ITEM_NAME_CN,\n" +
                    "	o_order_p.ORDER_PRODUCE_STATUS_CD,\n" +
                    "	o_order_p.ORDER_QC34,\n" +
                    "	o_order_p.ORDER_QC35,\n" +
                    "	o_order_p.ORDER_QC36,\n" +
                    "	o_order_p.ORDER_QC37,\n" +
                    "	o_order_p.ORDER_NUMBER,\n" +
                    "	o_order_p.ORDER_MATERIAL_COST,\n" +
                    "	o_order_p.ORDER_DESIGN_COST,\n" +
                    "	o_order_p.ORDER_PROCESS_COST,\n" +
                    "	o_order_p.ORDER_PACK_COST,\n" +
                    "	o_order_p.ORDER_EXPRESS_COST,\n" +
                    "	o_order_p.ORDER_SELL_ACCOUNT,\n" +
                    "	o_order_p.ORDER_OTHER_COST,\n" +
                    "	o_order_p.MATERIAL_SOURCE,\n" +
                    "	o_order_p.URGENT_CD,\n" +
                    "	o_order_p.AFTER_SALE_STATUS,\n" +
                    "	o_order_p.FIT_COMPLETE_FLAG,\n" +
                    "	o_order_p.REMARKS,\n" +
                    "	o_order_p.DELETE_FLAG,\n" +
                    "	o_order_p.VERSION,\n" +
                    "	o_order_p.CREATE_DATE,\n" +
                    "	o_order_p.UPDATE_DATE,\n" +
                    "	o_order_p.CREATE_USER,\n" +
                    "	o_order_p.UPDATE_USER,\n" +
                    "	o_order_p.SEL_KBN,\n" +
                    "	o_order_p.ACTUAL_PAYMENT_COST,\n" +
                    "	o_order_p.PREFERENTIAL_AMOUNT_COST,\n" +
                    "	o_order_p.PREFERENTIAL_PERCENTAGE,\n" +
                    "	DATE_FORMAT( o_order_p.ORDER_DATE, '%Y-%m-%d' ) AS ORDER_DATE,\n" +
                    "	print_flag.ITEM_NAME_CN AS PRINT_STATUS,\n" +
                    "	fr.BUSINESS_NO,\n" +
                    "	fc.CUSTOMER_NAME AS CUSTOMER_TRUE_NAME,\n" +
                    "	customer.MOBILE,\n" +
                    "	SUBSTRING_INDEX( s_style_p.STYLE_SIZE_CD, '-',- 1 ) AS SIZE, \n" +
                    "a_customer_address_p.CONSIGNEE AS `收货人姓名`,\n" +
                    "	CONCAT( a_customer_address_p.ADDRESS_PROVINCE_CD, a_customer_address_p.ADDRESS_CITY_CD, a_customer_address_p.ADDRESS_DISTRICT, a_customer_address_p.ADDRESS_DETAIL ) AS `收货人地址`,\n" +
                    "	a_customer_address_p.MOBILE AS `收货人电话`, \n" +
                    "  CONCAT(i_material_p.MATERIAL_CODE,i_material_p.MATERIAL_NAME_CN) AS MATERIAL_NAME_CN\n" +
                    "FROM\n" +
                    "(select * from o_order_p where DATE_SUB(CURDATE(), INTERVAL 30 DAY) <= date(CREATE_DATE)) o_order_p " +
                    "	LEFT JOIN s_style_p ON o_order_p.STYLE_ID = s_style_p.SYS_STYLE_ID\n" +
                    "	LEFT JOIN ( SELECT CONCAT( ITEM_CD, '-', ITEM_VALUE ) AS ITEM_VALUE, ITEM_NAME_CN FROM a_dict_p WHERE item_cd LIKE 'ORDER_STATUS' ) ORDER_STATUS ON ORDER_STATUS.ITEM_VALUE = o_order_p.ORDER_STATUS_CD\n" +
                    "	LEFT JOIN ( SELECT ITEM_NAME_CN, ITEM_VALUE FROM a_dict_p WHERE ITEM_CD = 'ORDER_PRINT_STATUS' ) print_flag ON o_order_p.PRINT_FLAG = print_flag.ITEM_VALUE\n" +
                    "	LEFT JOIN f_accounting_order_r fr ON o_order_p.ORDER_ID = fr.ORDER_ID\n" +
                    "	LEFT JOIN a_customer_fit_count_r fc ON fc.ID = s_style_p.CUSTOMER_COUNT_ID\n" +
                    "	LEFT JOIN a_customer_p customer ON o_order_p.CUSTOMER_ID = customer.CUSTOMER_ID \n" +
                     "	LEFT JOIN (SELECT * FROM a_customer_address_p WHERE DEFAULT_ADDR_FLAG='1') a_customer_address_p ON o_order_p .CUSTOMER_ID=a_customer_address_p.CUSTOMER_ID \n" +
                     "  LEFT JOIN i_material_p ON s_style_p.SYTLE_FABRIC_ID=i_material_p.MATERIAL_ID \n" +
                    "WHERE\n" +
                    "	o_order_p.ORDER_STATUS_CD IN ('" + str + "') \n" +
                    "   -- AND o_order_p.ORDER_ID IN ( SELECT ORDER_ID FROM o_order_brand_r WHERE SHOP_ID = '18' ) \n" +
                    "   AND o_order_p.ORDER_ID IN ( SELECT ORDER_ID FROM o_order_brand_r WHERE SHOP_ID  = '50' ) \n" +
                    "	AND o_order_p.SHOP_ID = '18' \n" +
                    "	AND o_order_p.DELETE_FLAG = 0 \n" +
                    "ORDER BY\n" +
                    "	o_order_p.order_date DESC";
            return SQLmtm.GetDataTable(sql);
        }
        public static DataTable get坚山订单(List<String> status)
        {
            String str;
            if (status == null || status.Count == 0)
            {
                throw new Exception("请选择订单状态");
            }
            else if (status.Count == 1)
            {
                str = status[0];
            }
            else
            {
                str = String.Join("','", status);
            }

            String sql = "SELECT\n" +
                    "	s_style_p.STYLE_NAME_CN,\n" +
                    "	s_style_p.STYLE_FIT_CD,\n" +
                    "	s_style_p.STYLE_CATEGORY_CD,\n" +
                    "	s_style_p.STYLE_SIZE_CD,\n" +
                    "	s_style_p.STYLE_SIZE_GROUP_CD,\n" +
                    "	o_order_p.ORDER_ID,\n" +
                    "	o_order_p.OGNIZATION_ID,\n" +
                    "	o_order_p.SHOP_ID,\n" +
                    "	o_order_p.SHOP_NAME,\n" +
                    "	o_order_p.ORDER_NO,\n" +
                    "	o_order_p.ORDER_TYPE_CD,\n" +
                    "	o_order_p.CUSTOM_ORDER_NO,\n" +
                    "	o_order_p.CUSTOM_NAME,\n" +
                    "	o_order_p.CUSTOM_MAKE_SHIRT,\n" +
                    "	o_order_p.TRANSIT_GROUP,\n" +
                    "	o_order_p.COUNTRY,\n" +
                    "	o_order_p.SLEEVE_FLAG,\n" +
                    "	o_order_p.CUSTOMER_ID,\n" +
                    "	o_order_p.CUSTOMER_NAME,\n" +
                    "	o_order_p.FACTORY_ID,\n" +
                    "	o_order_p.STYLE_ID,\n" +
                    "	o_order_p.REF_ORDER_ID,\n" +
                    "	o_order_p.SPECIAL_ORDER,\n" +
                    "	o_order_p.TRYON_ORDER,\n" +
                    "	o_order_p.FIT_STYLE_SIZE,\n" +
                    "	o_order_p.TAILOR_ID,\n" +
                    "	o_order_p.SHIPPING_DESTINATION,\n" +
                    "	o_order_p.PAYMENT_DATE,\n" +
                    "	o_order_p.PAYMENT_CONFIRM_DATE,\n" +
                    "	o_order_p.ORDER_ACCEPT_DATE,\n" +
                    "	o_order_p.ORDER_PRO_START_DATE,\n" +
                    "	o_order_p.ORDER_PRO_END_DATE,\n" +
                    "	o_order_p.ORDER_PACK_DATE,\n" +
                    "	o_order_p.ORDER_SHIPMENTS_DATE,\n" +
                    "	o_order_p.TARGET_DATE,\n" +
                    "	o_order_p.REAL_DATE,\n" +
                    "	o_order_p.ORDER_STATUS_CD,\n" +
                    "	ORDER_STATUS.ITEM_NAME_CN,\n" +
                    "	o_order_p.ORDER_PRODUCE_STATUS_CD,\n" +
                    "	o_order_p.ORDER_QC34,\n" +
                    "	o_order_p.ORDER_QC35,\n" +
                    "	o_order_p.ORDER_QC36,\n" +
                    "	o_order_p.ORDER_QC37,\n" +
                    "	o_order_p.ORDER_NUMBER,\n" +
                    "	o_order_p.ORDER_MATERIAL_COST,\n" +
                    "	o_order_p.ORDER_DESIGN_COST,\n" +
                    "	o_order_p.ORDER_PROCESS_COST,\n" +
                    "	o_order_p.ORDER_PACK_COST,\n" +
                    "	o_order_p.ORDER_EXPRESS_COST,\n" +
                    "	o_order_p.ORDER_SELL_ACCOUNT,\n" +
                    "	o_order_p.ORDER_OTHER_COST,\n" +
                    "	o_order_p.MATERIAL_SOURCE,\n" +
                    "	o_order_p.URGENT_CD,\n" +
                    "	o_order_p.AFTER_SALE_STATUS,\n" +
                    "	o_order_p.FIT_COMPLETE_FLAG,\n" +
                    "	o_order_p.REMARKS,\n" +
                    "	o_order_p.DELETE_FLAG,\n" +
                    "	o_order_p.VERSION,\n" +
                    "	o_order_p.CREATE_DATE,\n" +
                    "	o_order_p.UPDATE_DATE,\n" +
                    "	o_order_p.CREATE_USER,\n" +
                    "	o_order_p.UPDATE_USER,\n" +
                    "	o_order_p.SEL_KBN,\n" +
                    "	o_order_p.ACTUAL_PAYMENT_COST,\n" +
                    "	o_order_p.PREFERENTIAL_AMOUNT_COST,\n" +
                    "	o_order_p.PREFERENTIAL_PERCENTAGE,\n" +
                    "	DATE_FORMAT( o_order_p.ORDER_DATE, '%Y-%m-%d' ) AS ORDER_DATE,\n" +
                    "	print_flag.ITEM_NAME_CN AS PRINT_STATUS,\n" +
                    "	fr.BUSINESS_NO,\n" +
                    "	fc.CUSTOMER_NAME AS CUSTOMER_TRUE_NAME,\n" +
                    "	customer.MOBILE,\n" +
                    "	SUBSTRING_INDEX( s_style_p.STYLE_SIZE_CD, '-',- 1 ) AS SIZE, \n" +
                    "   CONCAT(i_material_p.MATERIAL_CODE,i_material_p.MATERIAL_NAME_CN) AS MATERIAL_NAME_CN \n" +
                    "FROM\n" +
                    "	o_order_p\n" +
                    "	LEFT JOIN s_style_p ON o_order_p.STYLE_ID = s_style_p.SYS_STYLE_ID\n" +
                    "	LEFT JOIN ( SELECT CONCAT( ITEM_CD, '-', ITEM_VALUE ) AS ITEM_VALUE, ITEM_NAME_CN FROM a_dict_p WHERE item_cd LIKE 'ORDER_STATUS' ) ORDER_STATUS ON ORDER_STATUS.ITEM_VALUE = o_order_p.ORDER_STATUS_CD\n" +
                    "	LEFT JOIN ( SELECT ITEM_NAME_CN, ITEM_VALUE FROM a_dict_p WHERE ITEM_CD = 'ORDER_PRINT_STATUS' ) print_flag ON o_order_p.PRINT_FLAG = print_flag.ITEM_VALUE\n" +
                    "	LEFT JOIN f_accounting_order_r fr ON o_order_p.ORDER_ID = fr.ORDER_ID\n" +
                    "	LEFT JOIN a_customer_fit_count_r fc ON fc.ID = s_style_p.CUSTOMER_COUNT_ID\n" +
                    "	LEFT JOIN a_customer_p customer ON o_order_p.CUSTOMER_ID = customer.CUSTOMER_ID \n" +
                    "   LEFT JOIN i_material_p ON s_style_p.SYTLE_FABRIC_ID=i_material_p.MATERIAL_ID \n" +
                    "WHERE\n" +
                    "	o_order_p.ORDER_STATUS_CD IN ('" + str + "') \n" +
                    "	AND o_order_p.SHOP_ID = '46' \n" +
                    "	AND o_order_p.DELETE_FLAG = 0 \n" +
                    "ORDER BY\n" +
                    "	o_order_p.order_date DESC";
            return SQLmtm.GetDataTable(sql);
        }
        public static DataTable get坚山美国订单(List<String> status)
        {
            String str;
            if (status == null || status.Count == 0)
            {
                throw new Exception("请选择订单状态");
            }
            else if (status.Count == 1)
            {
                str = status[0];
            }
            else
            {
                str = String.Join("','", status);
            }

            String sql = "SELECT\n" +
                    "	s_style_p.STYLE_NAME_CN,\n" +
                    "	s_style_p.STYLE_FIT_CD,\n" +
                    "	s_style_p.STYLE_CATEGORY_CD,\n" +
                    "	s_style_p.STYLE_SIZE_CD,\n" +
                    "	s_style_p.STYLE_SIZE_GROUP_CD,\n" +
                    "	o_order_p.ORDER_ID,\n" +
                    "	o_order_p.OGNIZATION_ID,\n" +
                    "	o_order_p.SHOP_ID,\n" +
                    "	o_order_p.SHOP_NAME,\n" +
                    "	o_order_p.ORDER_NO,\n" +
                    "	o_order_p.ORDER_TYPE_CD,\n" +
                    "	o_order_p.CUSTOM_ORDER_NO,\n" +
                    "	o_order_p.CUSTOM_NAME,\n" +
                    "	o_order_p.CUSTOM_MAKE_SHIRT,\n" +
                    "	o_order_p.TRANSIT_GROUP,\n" +
                    "	o_order_p.COUNTRY,\n" +
                    "	o_order_p.SLEEVE_FLAG,\n" +
                    "	o_order_p.CUSTOMER_ID,\n" +
                    "	o_order_p.CUSTOMER_NAME,\n" +
                    "	o_order_p.FACTORY_ID,\n" +
                    "	o_order_p.STYLE_ID,\n" +
                    "	o_order_p.REF_ORDER_ID,\n" +
                    "	o_order_p.SPECIAL_ORDER,\n" +
                    "	o_order_p.TRYON_ORDER,\n" +
                    "	o_order_p.FIT_STYLE_SIZE,\n" +
                    "	o_order_p.TAILOR_ID,\n" +
                    "	o_order_p.SHIPPING_DESTINATION,\n" +
                    "	o_order_p.PAYMENT_DATE,\n" +
                    "	o_order_p.PAYMENT_CONFIRM_DATE,\n" +
                    "	o_order_p.ORDER_ACCEPT_DATE,\n" +
                    "	o_order_p.ORDER_PRO_START_DATE,\n" +
                    "	o_order_p.ORDER_PRO_END_DATE,\n" +
                    "	o_order_p.ORDER_PACK_DATE,\n" +
                    "	o_order_p.ORDER_SHIPMENTS_DATE,\n" +
                    "	o_order_p.TARGET_DATE,\n" +
                    "	o_order_p.REAL_DATE,\n" +
                    "	o_order_p.ORDER_STATUS_CD,\n" +
                    "	ORDER_STATUS.ITEM_NAME_CN,\n" +
                    "	o_order_p.ORDER_PRODUCE_STATUS_CD,\n" +
                    "	o_order_p.ORDER_QC34,\n" +
                    "	o_order_p.ORDER_QC35,\n" +
                    "	o_order_p.ORDER_QC36,\n" +
                    "	o_order_p.ORDER_QC37,\n" +
                    "	o_order_p.ORDER_NUMBER,\n" +
                    "	o_order_p.ORDER_MATERIAL_COST,\n" +
                    "	o_order_p.ORDER_DESIGN_COST,\n" +
                    "	o_order_p.ORDER_PROCESS_COST,\n" +
                    "	o_order_p.ORDER_PACK_COST,\n" +
                    "	o_order_p.ORDER_EXPRESS_COST,\n" +
                    "	o_order_p.ORDER_SELL_ACCOUNT,\n" +
                    "	o_order_p.ORDER_OTHER_COST,\n" +
                    "	o_order_p.MATERIAL_SOURCE,\n" +
                    "	o_order_p.URGENT_CD,\n" +
                    "	o_order_p.AFTER_SALE_STATUS,\n" +
                    "	o_order_p.FIT_COMPLETE_FLAG,\n" +
                    "	o_order_p.REMARKS,\n" +
                    "	o_order_p.DELETE_FLAG,\n" +
                    "	o_order_p.VERSION,\n" +
                    "	o_order_p.CREATE_DATE,\n" +
                    "	o_order_p.UPDATE_DATE,\n" +
                    "	o_order_p.CREATE_USER,\n" +
                    "	o_order_p.UPDATE_USER,\n" +
                    "	o_order_p.SEL_KBN,\n" +
                    "	o_order_p.ACTUAL_PAYMENT_COST,\n" +
                    "	o_order_p.PREFERENTIAL_AMOUNT_COST,\n" +
                    "	o_order_p.PREFERENTIAL_PERCENTAGE,\n" +
                    "	DATE_FORMAT( o_order_p.ORDER_DATE, '%Y-%m-%d' ) AS ORDER_DATE,\n" +
                    "	print_flag.ITEM_NAME_CN AS PRINT_STATUS,\n" +
                    "	fr.BUSINESS_NO,\n" +
                    "	fc.CUSTOMER_NAME AS CUSTOMER_TRUE_NAME,\n" +
                    "	customer.MOBILE,\n" +
                    "	SUBSTRING_INDEX( s_style_p.STYLE_SIZE_CD, '-',- 1 ) AS SIZE, \n" +
                    "   CONCAT(i_material_p.MATERIAL_CODE,i_material_p.MATERIAL_NAME_CN) AS MATERIAL_NAME_CN \n" +
                    "FROM\n" +
                    "	o_order_p\n" +
                    "	LEFT JOIN s_style_p ON o_order_p.STYLE_ID = s_style_p.SYS_STYLE_ID\n" +
                    "	LEFT JOIN ( SELECT CONCAT( ITEM_CD, '-', ITEM_VALUE ) AS ITEM_VALUE, ITEM_NAME_CN FROM a_dict_p WHERE item_cd LIKE 'ORDER_STATUS' ) ORDER_STATUS ON ORDER_STATUS.ITEM_VALUE = o_order_p.ORDER_STATUS_CD\n" +
                    "	LEFT JOIN ( SELECT ITEM_NAME_CN, ITEM_VALUE FROM a_dict_p WHERE ITEM_CD = 'ORDER_PRINT_STATUS' ) print_flag ON o_order_p.PRINT_FLAG = print_flag.ITEM_VALUE\n" +
                    "	LEFT JOIN f_accounting_order_r fr ON o_order_p.ORDER_ID = fr.ORDER_ID\n" +
                    "	LEFT JOIN a_customer_fit_count_r fc ON fc.ID = s_style_p.CUSTOMER_COUNT_ID\n" +
                    "	LEFT JOIN a_customer_p customer ON o_order_p.CUSTOMER_ID = customer.CUSTOMER_ID \n" +
                    "   LEFT JOIN i_material_p ON s_style_p.SYTLE_FABRIC_ID=i_material_p.MATERIAL_ID\n" +
                    "WHERE\n" +
                    "	o_order_p.ORDER_STATUS_CD IN ('" + str + "') \n" +
                    "	AND o_order_p.SHOP_ID = '49' \n" +
                    "	AND o_order_p.DELETE_FLAG = 0 \n" +
                    "ORDER BY\n" +
                    "	o_order_p.order_date DESC";
            return SQLmtm.GetDataTable(sql);
        }
        public static DataTable get坚山美国订单看板()
        {
            String sql = "SELECT\n" +
                        "s_style_p.STYLE_NAME_CN,\n" +
                        "s_style_p.STYLE_FIT_CD,\n" +
                        "s_style_p.STYLE_SIZE_CD,\n" +
                        "o_order_p.SHOP_ID,\n" +
                        "o_order_p.SHOP_NAME,\n" +
                        "ORDER_STATUS.ITEM_NAME_CN,\n" +
                        "o_order_p.ORDER_ID,\n" +
                        "o_order_p.ORDER_NO,\n" +
                        "o_order_p.CUSTOM_NAME,\n" +
                        "o_order_p.CUSTOMER_ID,\n" +
                        "o_order_p.CUSTOMER_NAME,\n" +
                        "o_order_p.STYLE_ID,\n" +
                        "o_order_p.ORDER_NUMBER,\n" +
                        "DATE_FORMAT( o_order_p.ORDER_DATE, '%Y-%m-%d' ) AS ORDER_DATE,\n" +
                        "fr.BUSINESS_NO,\n" +
                        "fc.CUSTOMER_NAME AS CUSTOMER_TRUE_NAME,\n" +
                        "SUBSTRING_INDEX( s_style_p.STYLE_SIZE_CD, '-',- 1 ) AS SIZE \n" +
                        "FROM\n" +
                        "	o_order_p\n" +
                        "	LEFT JOIN s_style_p ON o_order_p.STYLE_ID = s_style_p.SYS_STYLE_ID\n" +
                        "	LEFT JOIN ( SELECT CONCAT( ITEM_CD, '-', ITEM_VALUE ) AS ITEM_VALUE, ITEM_NAME_CN FROM a_dict_p WHERE item_cd LIKE 'ORDER_STATUS' ) ORDER_STATUS ON ORDER_STATUS.ITEM_VALUE = o_order_p.ORDER_STATUS_CD\n" +
                        "	LEFT JOIN ( SELECT ITEM_NAME_CN, ITEM_VALUE FROM a_dict_p WHERE ITEM_CD = 'ORDER_PRINT_STATUS' ) print_flag ON o_order_p.PRINT_FLAG = print_flag.ITEM_VALUE\n" +
                        "	LEFT JOIN f_accounting_order_r fr ON o_order_p.ORDER_ID = fr.ORDER_ID\n" +
                        "	LEFT JOIN a_customer_fit_count_r fc ON fc.ID = s_style_p.CUSTOMER_COUNT_ID\n" +
                        "	LEFT JOIN a_customer_p customer ON o_order_p.CUSTOMER_ID = customer.CUSTOMER_ID \n" +
                        "WHERE\n" +
                        "	o_order_p.ORDER_STATUS_CD IN ( 'ORDER_STATUS-OS_20' ) \n" +
                        "	AND o_order_p.SHOP_ID = '49' \n" +
                        "	AND o_order_p.DELETE_FLAG = 0 \n" +
                        "	And datediff(now(),o_order_p.CREATE_DATE)<30\n" +
                        "ORDER BY\n" +
                        "	o_order_p.ORDER_DATE DESC;";
            return SQLmtm.GetDataTable(sql);
        }

        internal static 订单导出DTO getOrderInfo()
        {
            throw new NotImplementedException();
        }

        /// <summary>
        /// 根据订单id获取任务
        /// </summary>
        /// <param name="order_id"></param>
        /// <returns></returns>
        public static DataTable get订单任务(String order_id)
        {
            String sql = "SELECT\n" +
"	tr.remark_id,\n" +
"	tr.order_id,\n" +
"	tr.remark,\n" +
"	tr.file_name,\n" +
"	tr.template_id,\n" +
"	tr.`data`,\n" +
"	tr.style_id,\n" +
"	tr.ref_style_id,\n" +
"	tr.CREATE_DATE,\n" +
"	tr.parent_id,\n" +
"	tr.version,\n" +
"	tr.principal,\n" +
"	tr.serial_number,\n" +
"	-- tr.STATUS,\n" +
"	tr.A_jSON,\n" +
"	tr.A_FILE,\n" +
"	tt.template_name,\n" +
"	ttg.template_group_id,\n" +
"	ttg.template_group_name,\n" +
"	adp.ITEM_NAME_CN AS `status` \n" +
"FROM\n" +
"	t_remark AS tr\n" +
"	LEFT JOIN t_template AS tt ON tr.template_id = tt.template_id\n" +
"	LEFT JOIN t_template_group ttg ON tt.template_group_id = ttg.template_group_id\n" +
"	LEFT JOIN a_dict_p AS adp ON tr.STATUS = adp.ITEM_VALUE \n" +
"WHERE\n" +
"	tr.order_id = '" + order_id + "' \n" +
"	AND adp.ITEM_CD = 'MISSION_STATUS'";
            DataTable dt = SQLmtm.GetDataTable(sql);
            return dt;
        }
        /// <summary>
        /// 保存订单任务
        /// </summary>
        /// <param name="taskDTo"></param>
        public static void Save订单任务(TaskDTO taskDTo)
        {
            if (taskDTo.remark_id == "" || taskDTo.remark_id == null)
            {
                SQLmtm.DoInsert("t_remark", new string[] { "remark_id", "order_id", "remark", "file_name", "template_id", "data", "style_id", "ref_style_id", "serial_number", "status", "parent_id" }, new string[] { taskDTo.remark_id, taskDTo.order_id, taskDTo.remark, taskDTo.file_name, taskDTo.template_id, taskDTo.data, taskDTo.style_id, taskDTo.ref_style_id, taskDTo.serial_number, taskDTo.status, taskDTo.parent_id });
            }
            else
            {
                SQLmtm.DoInsert("t_remark", new string[] { "remark_id", "order_id", "remark", "file_name", "template_id", "data", "style_id", "ref_style_id", "serial_number", "status", "parent_id" }, new string[] { taskDTo.remark_id, taskDTo.order_id, taskDTo.remark, taskDTo.file_name, taskDTo.template_id, taskDTo.data, taskDTo.style_id, taskDTo.ref_style_id, taskDTo.serial_number, taskDTo.status, taskDTo.parent_id });
            }
        }
        /// <summary>
        /// 获取任务,读取任务
        /// </summary>
        /// <param name="remark_id"></param>
        public static DataRow GetTaskRead(String remark_id)
        {
            String sql = "SELECT\n" +
"	tr.remark_id,\n" +
"	tr.order_id,\n" +
"	tr.remark,\n" +
"	tr.file_name,\n" +
"	tr.template_id,\n" +
"	tr.`data`,\n" +
"	tr.style_id,\n" +
"	tr.ref_style_id,\n" +
"	tr.CREATE_DATE,\n" +
"	tr.parent_id,\n" +
"	tr.version,\n" +
"	tr.principal,\n" +
"	tr.serial_number,\n" +
"	tr.status,\n" +
"   tr.A_jSON,\n" +
"   tr.A_FILE,\n" +
"	tt.template_name,\n" +
"	ttg.template_group_id,\n" +
"	ttg.template_group_name\n" +
"FROM\n" +
"	t_remark AS tr\n" +
"	LEFT JOIN t_template AS tt ON tr.template_id = tt.template_id\n" +
"	LEFT JOIN t_template_group AS ttg ON tt.template_group_id = ttg.template_group_id \n" +
"WHERE\n" +
"	tr.remark_id = '" + remark_id + "'";
            return SQLmtm.GetDataRow(sql);
        }
        /// <summary>
        /// 保存Answer任务
        /// </summary>
        /// <param name="taskDTO"></param>
        public static void SaveAnswer任务(TaskDTO taskDTO)
        {
            SQLmtm.DoUpdate("t_remark", new string[] { "A_JSON", "A_FILE", "status" }, new string[] { taskDTO.A_JSON, taskDTO.A_FILE, taskDTO.status }, new string[] { "remark_id" }, new string[] { taskDTO.remark_id });
        }
        /// <summary>
        /// 获取裁剪条码
        /// </summary>
        /// <param name="BarCode"></param>
        /// <returns></returns>
        public static DataRow Get裁剪条码信息(String BarCode)
        {
            String sql = "SELECT\n" +
"	QR_ID,\n" +
"	QR_TYPE,\n" +
"	QR_BAR_CODE,\n" +
"	QR_CODE,\n" +
"	QR_NAME,\n" +
"	QR_OTHER1,\n" +
"	QR_OTHER2,\n" +
"	QR_OTHER3,\n" +
"	QR_OTHER4,\n" +
"	QR_OTHER5,\n" +
"	QR_OTHER6,\n" +
"	QR_OTHER7,\n" +
"	QR_OTHER8,\n" +
"	QR_OTHER9,\n" +
"	QR_OTHER0,\n" +
"	QR_OTHER10,\n" +
"	QR_OTHER11,\n" +
"	QR_OTHER12,\n" +
"	QR_OTHER13,\n" +
"	QR_OTHER14,\n" +
"	QR_OTHER15,\n" +
"	QR_OTHER16,\n" +
"	QR_OTHER17,\n" +
"	QR_OTHER18,\n" +
"	QR_OTHER19,\n" +
"	QR_OTHER20,\n" +
"	QR_OTHER21,\n" +
"	QR_OTHER22,\n" +
"	QR_OTHER23,\n" +
"	QR_OTHER24,\n" +
"	QR_OTHER25,\n" +
"	PRINT_FLAG,\n" +
"	ENABLE_FLAG,\n" +
"	DELETE_FLAG,\n" +
"	REMARKS,\n" +
"	VERSION,\n" +
"	CREATE_DATE,\n" +
"	CREATE_USER,\n" +
"	UPDATE_DATE,\n" +
"	UPDATE_USER,\n" +
"	QR_OTHER26,\n" +
"	QR_OTHER27,\n" +
"	QR_OTHER28,\n" +
"	QR_OTHER29,\n" +
"	QR_OTHER30,\n" +
"	QR_OTHER31,\n" +
"	QR_OTHER32,\n" +
"	QR_OTHER33,\n" +
"	QR_OTHER34,\n" +
"	QR_OTHER35 \n" +
"FROM\n" +
"	a_bar_code_p \n" +
"WHERE\n" +
"	QR_TYPE = 5 \n" +
"	AND QR_BAR_CODE = '" + BarCode + "' \n" +
"ORDER BY\n" +
"	QR_OTHER0,\n" +
"	QR_OTHER9";
            return SQLerp.GetDataRow(sql);
        }
        /// <summary>
        /// 通过orderid取styleid
        /// </summary>
        /// <param name="orderid"></param>
        /// <returns></returns>
        public static DataRow GetStyleidWithOrderid(String orderid)
        {
            String sql = "SELECT\n" +
"	ORDER_ID,\n" +
"	SHOP_ID,\n" +
"	OGNIZATION_ID,\n" +
"	STYLE_ID \n" +
"FROM\n" +
"	o_order_p \n" +
"WHERE\n" +
"	ORDER_ID = '" + orderid + "'";
            return SQLmtm.GetDataRow(sql);
        }
        /// <summary>
        /// 校验订单
        /// </summary>
        /// <param name="orderid"></param>
        /// <returns></returns>
        public static Boolean VerifyOrder(String orderid)
        {
            DataRow dr = SQLmtm.GetDataRow("SELECT\n" +
"	* \n" +
"FROM\n" +
"	o_order_p \n" +
"WHERE\n" +
"	ORDER_ID = '" + orderid + "'");
            if (dr == null)
            {
                return false;
            }
            else
            {
                return true;
            }
        }
        /// <summary>
        /// 通过订单id取订单STYLE_BAR_CODE
        /// </summary>
        /// <param name="orderid"></param>
        /// <returns></returns>
        public static String GetSBCWithOrderid(String orderid)
        {
            String sql = "SELECT\n" +
"	SUBSTRING_INDEX( ORDER_NO, '.',- 1 ) AS STYLE_BAR_CODE\n" +
"FROM\n" +
"	o_order_p \n" +
"WHERE\n" +
"	ORDER_ID = '" + orderid + "'";
            try
            {
                return SQLmtm.GetDataRow(sql)["STYLE_BAR_CODE"].ToString();
            }
            catch
            {
                return "";
            }
        }
        /// <summary>
        /// 通过订单id取订单ORDER_NO
        /// </summary>
        /// <param name="orderid"></param>
        /// <returns></returns>
        public static String GetOrderNoWithOrderid(String orderid)
        {
            String sql = "SELECT\n" +
            "	ORDER_NO\n" +
            "FROM\n" +
            "	o_order_p \n" +
            "WHERE\n" +
            "	ORDER_ID = '" + orderid + "'";
            try
            {
                return SQLmtm.GetDataRow(sql)["ORDER_NO"].ToString();
            }
            catch
            {
                return "";
            }
        }
        /// <summary>
        /// 更改订单打印状态
        /// </summary>
        /// <param name="orderid"></param>
        /// <param name="b"></param>
        public static void UpdataOrderPrintFlag(String orderid, bool b)
        {
            if (b == true)
            {
                SQLmtm.DoUpdate("o_order_p", new string[] { "PRINT_FLAG" }, new string[] { "1" }, new string[] { "ORDER_ID" }, new string[] { orderid });
            }
            else
            {
                SQLmtm.DoUpdate("o_order_p", new string[] { "PRINT_FLAG" }, new string[] { "0" }, new string[] { "ORDER_ID" }, new string[] { orderid });
            }
        }
        /// <summary>
        /// 根据orderno查询orderid,styleid,customerid
        /// </summary>
        /// <param name="OrderNo"></param>
        /// <returns></returns>
        public static DataRow GetOidSidCidByOno(String OrderNo)
        {
            String sql = "SELECT\n" +
                    "	ORDER_ID,\n" +
                    "	STYLE_ID,\n" +
                    "	CUSTOMER_ID,\n" +
                    "	ORDER_NO \n" +
                    "FROM\n" +
                    "	o_order_p \n" +
                    "WHERE\n" +
                    "	ORDER_NO = '" + OrderNo + "';";
            return SQLmtm.GetDataRow(sql);
        }

        public static DataTable Get样品订单(List<String> status)
        {
            String str;
            if (status == null || status.Count == 0)
            {
                throw new Exception("请选择订单状态");
            }
            else if (status.Count == 1)
            {
                str = status[0];
            }
            else
            {
                str = String.Join("','", status);
            }

            String sql = "SELECT\n" +
                    "	s_style_p.STYLE_NAME_CN,\n" +
                    "	s_style_p.STYLE_FIT_CD,\n" +
                    "	s_style_p.STYLE_CATEGORY_CD,\n" +
                    "	s_style_p.STYLE_SIZE_CD,\n" +
                    "	s_style_p.STYLE_SIZE_GROUP_CD,\n" +
                    "	o_order_p.ORDER_ID,\n" +
                    "	o_order_p.OGNIZATION_ID,\n" +
                    "	o_order_p.SHOP_ID,\n" +
                    "	o_order_p.SHOP_NAME,\n" +
                    "	o_order_p.ORDER_NO,\n" +
                    "	o_order_p.ORDER_TYPE_CD,\n" +
                    "	o_order_p.CUSTOM_ORDER_NO,\n" +
                    "	o_order_p.CUSTOM_NAME,\n" +
                    "	o_order_p.CUSTOM_MAKE_SHIRT,\n" +
                    "	o_order_p.TRANSIT_GROUP,\n" +
                    "	o_order_p.COUNTRY,\n" +
                    "	o_order_p.SLEEVE_FLAG,\n" +
                    "	o_order_p.CUSTOMER_ID,\n" +
                    "	o_order_p.CUSTOMER_NAME,\n" +
                    "	o_order_p.FACTORY_ID,\n" +
                    "	o_order_p.STYLE_ID,\n" +
                    "	o_order_p.REF_ORDER_ID,\n" +
                    "	o_order_p.SPECIAL_ORDER,\n" +
                    "	o_order_p.TRYON_ORDER,\n" +
                    "	o_order_p.FIT_STYLE_SIZE,\n" +
                    "	o_order_p.TAILOR_ID,\n" +
                    "	o_order_p.SHIPPING_DESTINATION,\n" +
                    "	o_order_p.PAYMENT_DATE,\n" +
                    "	o_order_p.PAYMENT_CONFIRM_DATE,\n" +
                    "	o_order_p.ORDER_ACCEPT_DATE,\n" +
                    "	o_order_p.ORDER_PRO_START_DATE,\n" +
                    "	o_order_p.ORDER_PRO_END_DATE,\n" +
                    "	o_order_p.ORDER_PACK_DATE,\n" +
                    "	o_order_p.ORDER_SHIPMENTS_DATE,\n" +
                    "	o_order_p.TARGET_DATE,\n" +
                    "	o_order_p.REAL_DATE,\n" +
                    "	o_order_p.ORDER_STATUS_CD,\n" +
                    "	ORDER_STATUS.ITEM_NAME_CN,\n" +
                    "	o_order_p.ORDER_PRODUCE_STATUS_CD,\n" +
                    "	o_order_p.ORDER_QC34,\n" +
                    "	o_order_p.ORDER_QC35,\n" +
                    "	o_order_p.ORDER_QC36,\n" +
                    "	o_order_p.ORDER_QC37,\n" +
                    "	o_order_p.ORDER_NUMBER,\n" +
                    "	o_order_p.ORDER_MATERIAL_COST,\n" +
                    "	o_order_p.ORDER_DESIGN_COST,\n" +
                    "	o_order_p.ORDER_PROCESS_COST,\n" +
                    "	o_order_p.ORDER_PACK_COST,\n" +
                    "	o_order_p.ORDER_EXPRESS_COST,\n" +
                    "	o_order_p.ORDER_SELL_ACCOUNT,\n" +
                    "	o_order_p.ORDER_OTHER_COST,\n" +
                    "	o_order_p.MATERIAL_SOURCE,\n" +
                    "	o_order_p.URGENT_CD,\n" +
                    "	o_order_p.AFTER_SALE_STATUS,\n" +
                    "	o_order_p.FIT_COMPLETE_FLAG,\n" +
                    "	o_order_p.REMARKS,\n" +
                    "	o_order_p.DELETE_FLAG,\n" +
                    "	o_order_p.VERSION,\n" +
                    "	o_order_p.CREATE_DATE,\n" +
                    "	o_order_p.UPDATE_DATE,\n" +
                    "	o_order_p.CREATE_USER,\n" +
                    "	o_order_p.UPDATE_USER,\n" +
                    "	o_order_p.SEL_KBN,\n" +
                    "	o_order_p.ACTUAL_PAYMENT_COST,\n" +
                    "	o_order_p.PREFERENTIAL_AMOUNT_COST,\n" +
                    "	o_order_p.PREFERENTIAL_PERCENTAGE,\n" +
                    "	DATE_FORMAT( o_order_p.ORDER_DATE, '%Y-%m-%d' ) AS ORDER_DATE,\n" +
                    "	print_flag.ITEM_NAME_CN AS PRINT_STATUS,\n" +
                    "	fr.BUSINESS_NO,\n" +
                    "	fc.CUSTOMER_NAME AS CUSTOMER_TRUE_NAME,\n" +
                    "	customer.MOBILE,\n" +
                    "	SUBSTRING_INDEX( s_style_p.STYLE_SIZE_CD, '-',- 1 ) AS SIZE, \n" +
                    "a_customer_address_p.CONSIGNEE AS `收货人姓名`,\n" +
                    "	CONCAT( a_customer_address_p.ADDRESS_PROVINCE_CD, a_customer_address_p.ADDRESS_CITY_CD, a_customer_address_p.ADDRESS_DISTRICT, a_customer_address_p.ADDRESS_DETAIL ) AS `收货人地址`,\n" +
                    "	a_customer_address_p.MOBILE AS `收货人电话`, \n" +
                    "  CONCAT(i_material_p.MATERIAL_CODE,i_material_p.MATERIAL_NAME_CN) AS MATERIAL_NAME_CN\n" +
                    "FROM\n" +
                    "(select * from o_order_p where DATE_SUB(CURDATE(), INTERVAL 30 DAY) <= date(CREATE_DATE)) o_order_p " +
                    "	LEFT JOIN s_style_p ON o_order_p.STYLE_ID = s_style_p.SYS_STYLE_ID\n" +
                    "	LEFT JOIN ( SELECT CONCAT( ITEM_CD, '-', ITEM_VALUE ) AS ITEM_VALUE, ITEM_NAME_CN FROM a_dict_p WHERE item_cd LIKE 'ORDER_STATUS' ) ORDER_STATUS ON ORDER_STATUS.ITEM_VALUE = o_order_p.ORDER_STATUS_CD\n" +
                    "	LEFT JOIN ( SELECT ITEM_NAME_CN, ITEM_VALUE FROM a_dict_p WHERE ITEM_CD = 'ORDER_PRINT_STATUS' ) print_flag ON o_order_p.PRINT_FLAG = print_flag.ITEM_VALUE\n" +
                    "	LEFT JOIN f_accounting_order_r fr ON o_order_p.ORDER_ID = fr.ORDER_ID\n" +
                    "	LEFT JOIN a_customer_fit_count_r fc ON fc.ID = s_style_p.CUSTOMER_COUNT_ID\n" +
                    "	LEFT JOIN a_customer_p customer ON o_order_p.CUSTOMER_ID = customer.CUSTOMER_ID \n" +
                     "	LEFT JOIN (SELECT * FROM a_customer_address_p WHERE DEFAULT_ADDR_FLAG='1') a_customer_address_p ON o_order_p .CUSTOMER_ID=a_customer_address_p.CUSTOMER_ID \n" +
                     "  LEFT JOIN i_material_p ON s_style_p.SYTLE_FABRIC_ID=i_material_p.MATERIAL_ID \n" +
                    "WHERE\n" +
                    "	o_order_p.ORDER_STATUS_CD IN ('" + str + "') \n" +
                    "   -- AND o_order_p.ORDER_ID IN ( SELECT ORDER_ID FROM o_order_brand_r WHERE SHOP_ID = '18' ) \n" +
                    "   AND o_order_p.ORDER_ID IN ( SELECT ORDER_ID FROM o_order_brand_r WHERE SHOP_ID  = '48' ) \n" +
                    "	AND o_order_p.SHOP_ID = '18' \n" +
                    "	AND o_order_p.DELETE_FLAG = 0 \n" +
                    "ORDER BY\n" +
                    "	o_order_p.order_date DESC";
            return SQLmtm.GetDataTable(sql);
        }
        public static DataTable GetM2店铺订单(List<String> status)
        {
            String str;
            if (status == null || status.Count == 0)
            {
                throw new Exception("请选择订单状态");
            }
            else if (status.Count == 1)
            {
                str = status[0];
            }
            else
            {
                str = String.Join("','", status);
            }

            String sql = "SELECT\n" +
                    "	s_style_p.STYLE_NAME_CN,\n" +
                    "	s_style_p.STYLE_FIT_CD,\n" +
                    "	s_style_p.STYLE_CATEGORY_CD,\n" +
                    "	s_style_p.STYLE_SIZE_CD,\n" +
                    "	s_style_p.STYLE_SIZE_GROUP_CD,\n" +
                    "	o_order_p.ORDER_ID,\n" +
                    "	o_order_p.OGNIZATION_ID,\n" +
                    "	o_order_p.SHOP_ID,\n" +
                    "	o_order_p.SHOP_NAME,\n" +
                    "	o_order_p.ORDER_NO,\n" +
                    "	o_order_p.ORDER_TYPE_CD,\n" +
                    "	o_order_p.CUSTOM_ORDER_NO,\n" +
                    "	o_order_p.CUSTOM_NAME,\n" +
                    "	o_order_p.CUSTOM_MAKE_SHIRT,\n" +
                    "	o_order_p.TRANSIT_GROUP,\n" +
                    "	o_order_p.COUNTRY,\n" +
                    "	o_order_p.SLEEVE_FLAG,\n" +
                    "	o_order_p.CUSTOMER_ID,\n" +
                    "	o_order_p.CUSTOMER_NAME,\n" +
                    "	o_order_p.FACTORY_ID,\n" +
                    "	o_order_p.STYLE_ID,\n" +
                    "	o_order_p.REF_ORDER_ID,\n" +
                    "	o_order_p.SPECIAL_ORDER,\n" +
                    "	o_order_p.TRYON_ORDER,\n" +
                    "	o_order_p.FIT_STYLE_SIZE,\n" +
                    "	o_order_p.TAILOR_ID,\n" +
                    "	o_order_p.SHIPPING_DESTINATION,\n" +
                    "	o_order_p.PAYMENT_DATE,\n" +
                    "	o_order_p.PAYMENT_CONFIRM_DATE,\n" +
                    "	o_order_p.ORDER_ACCEPT_DATE,\n" +
                    "	o_order_p.ORDER_PRO_START_DATE,\n" +
                    "	o_order_p.ORDER_PRO_END_DATE,\n" +
                    "	o_order_p.ORDER_PACK_DATE,\n" +
                    "	o_order_p.ORDER_SHIPMENTS_DATE,\n" +
                    "	o_order_p.TARGET_DATE,\n" +
                    "	o_order_p.REAL_DATE,\n" +
                    "	o_order_p.ORDER_STATUS_CD,\n" +
                    "	t_order_status_p.ORDER_STATUS AS ITEM_NAME_CN,\n" +
                    "	o_order_p.ORDER_PRODUCE_STATUS_CD,\n" +
                    "	o_order_p.ORDER_QC34,\n" +
                    "	o_order_p.ORDER_QC35,\n" +
                    "	o_order_p.ORDER_QC36,\n" +
                    "	o_order_p.ORDER_QC37,\n" +
                    "	o_order_p.ORDER_NUMBER,\n" +
                    "	o_order_p.ORDER_MATERIAL_COST,\n" +
                    "	o_order_p.ORDER_DESIGN_COST,\n" +
                    "	o_order_p.ORDER_PROCESS_COST,\n" +
                    "	o_order_p.ORDER_PACK_COST,\n" +
                    "	o_order_p.ORDER_EXPRESS_COST,\n" +
                    "	o_order_p.ORDER_SELL_ACCOUNT,\n" +
                    "	o_order_p.ORDER_OTHER_COST,\n" +
                    "	o_order_p.MATERIAL_SOURCE,\n" +
                    "	o_order_p.URGENT_CD,\n" +
                    "	o_order_p.AFTER_SALE_STATUS,\n" +
                    "	o_order_p.FIT_COMPLETE_FLAG,\n" +
                    "	o_order_p.REMARKS,\n" +
                    "	o_order_p.DELETE_FLAG,\n" +
                    "	o_order_p.VERSION,\n" +
                    "	o_order_p.CREATE_DATE,\n" +
                    "	o_order_p.UPDATE_DATE,\n" +
                    "	o_order_p.CREATE_USER,\n" +
                    "	o_order_p.UPDATE_USER,\n" +
                    "	o_order_p.SEL_KBN,\n" +
                    "	o_order_p.ACTUAL_PAYMENT_COST,\n" +
                    "	o_order_p.PREFERENTIAL_AMOUNT_COST,\n" +
                    "	o_order_p.PREFERENTIAL_PERCENTAGE,\n" +
                    "	DATE_FORMAT( o_order_p.ORDER_DATE, '%Y-%m-%d' ) AS ORDER_DATE,\n" +
                    "	print_flag.ITEM_NAME_CN AS PRINT_STATUS,\n" +
                    "	fr.BUSINESS_NO,\n" +
                    "	fc.CUSTOMER_NAME AS CUSTOMER_TRUE_NAME,\n" +
                    "	customer.MOBILE,\n" +
                    "	SUBSTRING_INDEX( s_style_p.STYLE_SIZE_CD, '-',- 1 ) AS SIZE, \n" +
                    "a_customer_address_p.CONSIGNEE AS `收货人姓名`,\n" +
                    "	CONCAT( a_customer_address_p.ADDRESS_PROVINCE_CD, a_customer_address_p.ADDRESS_CITY_CD, a_customer_address_p.ADDRESS_DISTRICT, a_customer_address_p.ADDRESS_DETAIL ) AS `收货人地址`,\n" +
                    "	a_customer_address_p.MOBILE AS `收货人电话`, \n" +
                    "  CONCAT(i_material_p.MATERIAL_CODE,i_material_p.MATERIAL_NAME_CN) AS MATERIAL_NAME_CN\n" +
                    "FROM\n" +
                    "(select * from o_order_p where DATE_SUB(CURDATE(), INTERVAL 30 DAY) <= date(CREATE_DATE)) o_order_p " +
                    "	LEFT JOIN s_style_p ON o_order_p.STYLE_ID = s_style_p.SYS_STYLE_ID\n" +
                    "	LEFT JOIN ( SELECT CONCAT( ITEM_CD, '-', ITEM_VALUE ) AS ITEM_VALUE, ITEM_NAME_CN FROM a_dict_p WHERE item_cd LIKE 'ORDER_STATUS' ) ORDER_STATUS ON ORDER_STATUS.ITEM_VALUE = o_order_p.ORDER_STATUS_CD\n" +
                    "	LEFT JOIN ( SELECT ITEM_NAME_CN, ITEM_VALUE FROM a_dict_p WHERE ITEM_CD = 'ORDER_PRINT_STATUS' ) print_flag ON o_order_p.PRINT_FLAG = print_flag.ITEM_VALUE\n" +
                    "	LEFT JOIN f_accounting_order_r fr ON o_order_p.ORDER_ID = fr.ORDER_ID\n" +
                    "	LEFT JOIN a_customer_fit_count_r fc ON fc.ID = s_style_p.CUSTOMER_COUNT_ID\n" +
                    "	LEFT JOIN a_customer_p customer ON o_order_p.CUSTOMER_ID = customer.CUSTOMER_ID \n" +
                    "	LEFT JOIN t_order_status_p ON o_order_p.ORDER_ID = t_order_status_p.ORDER_ID \n" +
                     "	LEFT JOIN (SELECT * FROM a_customer_address_p WHERE DEFAULT_ADDR_FLAG='1') a_customer_address_p ON o_order_p .CUSTOMER_ID=a_customer_address_p.CUSTOMER_ID \n" +
                     "  LEFT JOIN i_material_p ON s_style_p.SYTLE_FABRIC_ID=i_material_p.MATERIAL_ID \n" +
                    "WHERE\n" +
                    "	o_order_p.ORDER_STATUS_CD IN ('" + str + "') \n" +
                    "   -- AND o_order_p.ORDER_ID IN ( SELECT ORDER_ID FROM o_order_brand_r WHERE SHOP_ID = '18' ) \n" +
                    "   AND o_order_p.ORDER_ID IN ( SELECT ORDER_ID FROM o_order_brand_r WHERE SHOP_ID  = '51' ) \n" +
                    "	-- AND o_order_p.SHOP_ID = '18' \n" +
                    "	AND o_order_p.DELETE_FLAG = 0 \n" +
                    "ORDER BY\n" +
                    "	o_order_p.order_date DESC";
            return SQLmtm.GetDataTable(sql);
        }
        /// <summary>
        /// 获取最大orderID
        /// </summary>
        /// <returns></returns>
        public static String GetMaxOrderID()
        {
            DataRow ORDER_ID = SQLmtm.GetDataRow("SELECT MAX(ORDER_ID) AS ORDER_ID FROM `o_order_p`");
            int order_id = Convert.ToInt32(ORDER_ID["ORDER_ID"]);
            return order_id.ToString();
        }

        public static 订单导出DTO getOrderInfo(String OrderId, List<尺寸呈现dto> 尺寸呈现, List<DTODesignPoints> Dto设计点s,Image pic)
        {
            String sql = "SELECT\n" +
                "	o_order_p.ORDER_ID,\n" +
                "	o_order_p.ORDER_NO,-- 订单号\n" +
                "	o_order_p.ORDER_NUMBER,-- 订单数量\n" +
                "	o_order_p.ORDER_DATE,-- 订单日期\n" +
                "	o_order_p.CUSTOM_NAME,-- 客户名称\n" +
                "	o_order_p.CUSTOMER_ID,\n" +
                "	o_order_p.SHOP_NAME,-- 店名\n" +
                "	o_order_p.ORDER_SHIPMENTS_DATE,-- 船期\n" +
                "	o_order_p.STYLE_ID, -- 款号	\n" +
                "	o_order_p.REMARKS, -- 备注 	\n" +
                "	o_order_p.CUSTOMER_ID, -- 客户id	\n" +
                "	DATE_ADD(o_order_p.ORDER_DATE,INTERVAL 7 day) AS ORDER_DUE_DATE \n" +
                "FROM\n" +
                "	o_order_p \n" +
                "WHERE\n" +
                "	o_order_p.ORDER_ID = \""+ OrderId + "\"";
            DataRow dataRow订单 = SQLmtm.GetDataRow(sql);
            String CUSTOMER_ID = dataRow订单["CUSTOMER_ID"].ToString();
 
            DataRow dataRow款式 = OrderService.get款式ByStyleID(dataRow订单["STYLE_ID"].ToString());
            DataRow dataRow面料 = OrderService.get面料BySYTLE_FABRIC_ID(dataRow款式["SYTLE_FABRIC_ID"].ToString()) ;
            return new 订单导出DTO(dataRow订单, dataRow款式, dataRow面料, 尺寸呈现, Dto设计点s, WinformCustomerService.get客户量体值(CUSTOMER_ID),pic);
        }

        public static void getOrderInfo(String TaskId) {
            //  1、从打样任务（样品下单）中取出json和面料ID、款式ID

            //  2、
            //  DataRow dataRow款式 = OrderService.get款式ByStyleID(dataRow订单["STYLE_ID"].ToString());
            //  DataRow dataRow面料 = OrderService.get面料BySYTLE_FABRIC_ID(dataRow款式["SYTLE_FABRIC_ID"].ToString());

            //  3、
            //  return new 订单导出DTO();

        }

        /// <summary>
        /// 取款式
        /// </summary>
        /// <param name="STYLE_ID"></param>
        /// <returns></returns>
        private static DataRow get款式ByStyleID(String STYLE_ID) {
            String sql = "SELECT\n" +
                    "	STYLE_NAME_CN,-- 款式\n" +
                    "	STYLE_DESIGN_TYPE,\n" +
                    "	SYTLE_FABRIC_ID,\n" +
                    "	STYLE_MAKE_TYPE,-- 缝制方式\n" +
                    "	Style_FIT_CD,-- 版型\n" +
                    "CASE\n" +
                    "		STYLE_SIZE_GROUP_CD \n" +
                    "		WHEN \"GROUP_SIZE-IGS_GROUP_SIZE\" THEN\n" +
                    "		\"国际尺码组\" \n" +
                    "		WHEN \"GROUP_SIZE-EGS_GROUP_SIZE\" THEN\n" +
                    "		\"欧洲尺码组\" \n" +
                    "	END AS STYLE_SIZE_GROUP_CD,-- 尺码组\n" +
                    "	STYLE_SIZE_CD,-- 尺码\n" +
                    "	a_dict_p.ITEM_NAME_CN AS MAKE_TYPE \n" +
                    "FROM\n" +
                    "	s_style_p\n" +
                    "	LEFT JOIN a_dict_p ON a_dict_p.ITEM_VALUE = SUBSTRING_INDEX( s_style_p.STYLE_MAKE_TYPE, '-',- 1 ) \n" +
                    "WHERE\n" +
                    "	SYS_STYLE_ID = '" + STYLE_ID + "';";
            return SQLmtm.GetDataRow(sql);
        }

        /// <summary>
        /// 取面料
        /// </summary>
        /// <param name="SYTLE_FABRIC_ID"></param>
        /// <returns></returns>
        private static DataRow get面料BySYTLE_FABRIC_ID(String SYTLE_FABRIC_ID) {
            String sql = "SELECT\n" +
                    "	i_material_p.MATERIAL_CODE,-- 面料品号\n" +
                    "	i_material_p.MATERIAL_SPEC,-- 幅宽\n" +
                    "	i_material_p.MATERIAL_STITCH,-- 面料针码\n" +
                    "	i_material_p.MATERIAL_STYLE, -- 物料风格\n" +
                    "	i_material_p.MATERIAL_NAME_CN, -- 物料名称\n" +
                    "	i_material_p.MATERIAL_WEAVE,\n" +
                    "	a_dict_p.ITEM_NAME_CN AS `WEAVE`,\n" +
                    "	a_dict_p1.ITEM_NAME_CN AS `STYLE`\n" +
                    "FROM\n" +
                    "	i_material_p \n" +
                    "	LEFT JOIN a_dict_p ON a_dict_p.ITEM_VALUE=SUBSTRING_INDEX(i_material_p.MATERIAL_WEAVE,'-',-1)\n" +
                    "	LEFT JOIN a_dict_p AS a_dict_p1 ON a_dict_p1.ITEM_VALUE=SUBSTRING_INDEX(i_material_p.MATERIAL_STYLE,'-',-1)\n" +
                    "WHERE\n" +
                    "	i_material_p.MATERIAL_ID = '"+ SYTLE_FABRIC_ID + "';";
            return SQLmtm.GetDataRow(sql);
        }

        public static DTO样衣订单导出 getSampleOrder(String OrderId, ImageUtil imageUtil)
        {
            String sql = "SELECT\n" +
                "	o_order_p.ORDER_ID,\n" +
                "	o_order_p.ORDER_NO,-- 订单号\n" +
                "	o_order_p.ORDER_NUMBER,-- 订单数量\n" +
                "	o_order_p.ORDER_DATE,-- 订单日期\n" +
                "	o_order_p.CUSTOM_NAME,-- 客户名称\n" +
                "	o_order_p.CUSTOMER_ID,\n" +
                "	o_order_p.SHOP_NAME,-- 店名\n" +
                "	o_order_p.ORDER_SHIPMENTS_DATE,-- 船期\n" +
                "	o_order_p.STYLE_ID, -- 款号	\n" +
                "	o_order_p.REMARKS, -- 备注 	\n" +
                "	o_order_p.CUSTOMER_ID -- 客户id	\n" +
                "FROM\n" +
                "	o_order_p \n" +
                "WHERE\n" +
                "	o_order_p.ORDER_ID = \"" + OrderId + "\"";
            DataRow dataRow订单 = SQLmtm.GetDataRow(sql);
            String CUSTOMER_ID = dataRow订单["CUSTOMER_ID"].ToString();
            sql = "SELECT\n" +
                "	STYLE_NAME_CN,	-- 款式\n" +
                "	STYLE_DESIGN_TYPE, \n" +
                "	SYTLE_FABRIC_ID ,\n" +
                "	STYLE_MAKE_TYPE, -- 缝制方式\n" +
                "	Style_FIT_CD, -- 版型\n" +
                "CASE\n" +
                "		STYLE_SIZE_GROUP_CD \n" +
                "		WHEN \"GROUP_SIZE-IGS_GROUP_SIZE\" THEN\n" +
                "		\"国际尺码组\" \n" +
                "		WHEN \"GROUP_SIZE-EGS_GROUP_SIZE\" THEN\n" +
                "		\"欧洲尺码组\" \n" +
                "	END AS STYLE_SIZE_GROUP_CD,-- 尺码组\n" +
                "	STYLE_SIZE_CD -- 尺码 \n" +
                "FROM\n" +
                "	s_style_p \n" +
                "WHERE\n" +
                "	SYS_STYLE_ID = '" + dataRow订单["STYLE_ID"].ToString() + "'";
            DataRow dataRow款式 = SQLmtm.GetDataRow(sql);

            sql = "SELECT\n" +
                "	i_material_p.MATERIAL_CODE,-- 面料品号\n" +
                "	i_material_p.MATERIAL_SPEC,-- 幅宽\n" +
                "	i_material_p.MATERIAL_STITCH,-- 面料针码\n" +
                "	i_material_p.MATERIAL_STYLE -- 物料风格	\n" +
                "FROM\n" +
                "	i_material_p \n" +
                "WHERE \n" +
                " i_material_p.MATERIAL_ID='" + dataRow款式["SYTLE_FABRIC_ID"].ToString() + "'";
            DataRow dataRow面料 = SQLmtm.GetDataRow(sql);
            return new DTO样衣订单导出(dataRow订单, dataRow款式, dataRow面料, imageUtil);
        }
        /// <summary>
        /// 订单基本信息获取
        /// </summary>
        /// <param name="orderid"></param>
        /// <returns></returns>
        public static 订单基本信息 Get订单基本信息(String orderid)
        {
            String ORDER_NO;
            String 尺寸;
            String BUSINESS_NO;
            String 销售信息姓名;
            String 销售信息电话;
            String 销售信息性别;
            String 收货人姓名;
            String 收货人电话;
            String 收货人地址;
            #region sql文
            String sql = "SELECT\n" +
                            "	o_order_p.ORDER_NO,\n" +
                            "	SUBSTRING_INDEX( s_style_p.STYLE_SIZE_CD, '-',- 1 ) AS 尺寸,\n" +
                            "	f_accounting_order_r.BUSINESS_NO,\n" +
                            "	CONCAT(a_customer_p.CUSTOMER_FIRST_NAME,a_customer_p.CUSTOMER_LAST_NAME) AS 销售信息姓名,\n" +
                            "	a_customer_p.MOBILE AS 销售信息电话,\n" +
                            "	( CASE a_customer_p.SEX_CD WHEN 'SEX-M_10' THEN '男' ELSE '女' END ) AS 销售信息性别,\n" +
                            "  f_accounting_p.ADDRESSEE_NAME AS 收货人姓名,\n" +
                            "	f_accounting_p.ADDRESSEE_TEL AS 收货人电话,\n" +
                            "	CONCAT(f_accounting_p.ADDRESS_PROVINCE_CD,f_accounting_p.ADDRESS_CITY_CD,f_accounting_p.ADDRESS_DISTRICT,f_accounting_p.ADDRESS_DETAIL,f_accounting_p.ZIP_CODE) AS 收货人地址\n" +
                            "FROM\n" +
                            "	o_order_p\n" +
                            "	LEFT JOIN s_style_p ON o_order_p.STYLE_ID = s_style_p.SYS_STYLE_ID\n" +
                            "	LEFT JOIN f_accounting_order_r ON o_order_p.ORDER_ID = f_accounting_order_r.ORDER_ID\n" +
                            "	LEFT JOIN a_customer_p ON o_order_p.CUSTOMER_ID = a_customer_p.CUSTOMER_ID\n" +
                            "	LEFT JOIN f_accounting_p ON f_accounting_p.BUSINESS_NO = f_accounting_order_r.BUSINESS_NO \n" +
                            "WHERE\n" +
                            "	o_order_p.ORDER_ID = '" + orderid + "';";
            #endregion
            DataRow dr = SQLmtm.GetDataRow(sql);
            ORDER_NO = dr["ORDER_NO"].ToString();
            尺寸 = dr["尺寸"].ToString();
            BUSINESS_NO = dr["BUSINESS_NO"].ToString();
            销售信息姓名 = dr["销售信息姓名"].ToString();
            销售信息电话 = dr["销售信息电话"].ToString();
            销售信息性别 = dr["销售信息性别"].ToString();
            收货人姓名 = dr["收货人姓名"].ToString();
            收货人电话 = dr["收货人电话"].ToString();
            收货人地址 = dr["收货人地址"].ToString();
            return new 订单基本信息(ORDER_NO, 尺寸, BUSINESS_NO, 销售信息姓名, 销售信息电话, 销售信息性别, 收货人姓名, 收货人电话, 收货人地址);
        }
        /// <summary>
        /// 订单备注获取
        /// </summary>
        /// <param name="orderid"></param>
        /// <returns></returns>
        public static String GetRemarks(String orderid)
        {
            return SQLmtm.GetDataRow("SELECT REMARKS FROM o_order_p WHERE ORDER_ID='" + orderid + "';")["REMARKS"].ToString();
        }
        /// <summary>
        /// 更改订单备注
        /// </summary>
        /// <param name="orderid"></param>
        /// <param name="remark"></param>
        /// <returns></returns>
        public static Boolean ChangeOrderRemark(String orderid,String remark)
        {
            String sql = "UPDATE `o_order_p` \n" +
                    "SET `REMARKS` = '" + remark + "' \n" +
                    "WHERE\n" +
                    "	`ORDER_ID` = " + orderid + ";";
            try
            {
                SQLmtm.ExecuteSql(sql);
                if ("true".Equals(RestCall.httpGetMethod(URL.接口url + "/barcode/updateOrderCommitRemark?orderId=" + orderid + "&remarks=" + remark)))
                {
                    return true;
                }
                else
                {
                    return false;
                }
            }
            catch
            {
                return false;
            }
        }
        /// <summary>
        /// 删除订单
        /// </summary>
        /// <param name="orderid"></param>
        /// <returns></returns>
        public static Boolean DeleteOrder(String orderid)
        {
            String sql= "UPDATE `fragsmart-mtm`.`o_order_p` \n" +
                    "SET `DELETE_FLAG` = '1' \n" +
                    "WHERE\n" +
                    "	`ORDER_ID` = " + orderid + ";";
            try
            {
                SQLmtm.ExecuteSql(sql);
                return true;
            }
            catch
            {
                return false;
            }
        }
        /// <summary>
        /// 取refstyleid
        /// </summary>
        /// <param name="styleid"></param>
        /// <returns></returns>
        public static void getRefStyleidByStyleid(String styleid, Dto定制下单 dto)
        {
            String sql = "SELECT\n" +
                "	REF_STYLE_ID,\n" +
                "	STYLE_NAME_CN \n" +
                "FROM\n" +
                "	`s_style_p` \n" +
                "WHERE\n" +
                "	SYS_STYLE_ID = '" + styleid + "'";
            try
            {
                dto.Style_Id = SQLmtm.GetDataRow(sql)["REF_STYLE_ID"].ToString();
                dto.STYLE_NAME_CN = SQLmtm.GetDataRow(sql)["STYLE_NAME_CN"].ToString();
            }
            catch
            {
                dto.Style_Id = "";
                dto.STYLE_NAME_CN = "";
            }
        }
    }
}
